Skip to content

Instantly share code, notes, and snippets.

@kisom
Created May 28, 2012 19:21
Show Gist options
  • Save kisom/2820784 to your computer and use it in GitHub Desktop.
Save kisom/2820784 to your computer and use it in GitHub Desktop.
copy ssh key to remote host
#!/bin/sh
if [ -z "$1" ]; then
echo "usage: $0 [user@]host [pubkey]"
exit 1;
fi
if [ -z "$2" ]; then
PUBKEY="$(cat ${HOME}/.ssh/id_rsa.pub)"
else
PUBKEY="$(cat $2)"
fi
ssh $1 echo "${PUBKEY} >> ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment