Skip to content

Instantly share code, notes, and snippets.

@cameron
Created September 10, 2013 19:39
Show Gist options
  • Save cameron/6514484 to your computer and use it in GitHub Desktop.
Save cameron/6514484 to your computer and use it in GitHub Desktop.
put your pub key on a remote machine
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