Created
September 10, 2013 19:39
-
-
Save cameron/6514484 to your computer and use it in GitHub Desktop.
put your pub key on a remote machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ $# -lt 2 ]; then | |
echo "Usage: $0 <key-file> <host> [<user>]" | |
return | |
fi | |
key="$1" | |
host="$2" | |
user="$USER" | |
if [ $# -eq 3 ]; then | |
user=$3 | |
fi | |
tmp_file=/tmp/temporary-ssh-key | |
scp $key $user@$host:$tmp_file | |
ssh -l $user $host "mkdir -p ~/.ssh/; cat $tmp_file >> ~/.ssh/authorized_keys; rm $tmp_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment