Change email address from drexel to tremily.
[blog.git] / posts / SSH / ssh-remote.sh
1 #!/bin/bash
2 #
3 # Set up keyed login to a remote host.
4 #
5 # usage: ssh-remote.sh [[uname@]remote_hostname
6
7 if [ $# -ne 1 ]; then
8     echo "usage: ssh-remote [uname@]remote_hostname"
9     exit 1
10 fi
11
12 RHOST="$1"
13 PUBLIC_KEY="$HOME/.ssh/id_rsa.pub"
14 F=".ssh/authorized_keys"
15
16 cat "$PUBLIC_KEY" | ssh $RHOST "touch $F; chmod 600 $F; cat >> $F"
17
18 exit 0