Skip to content

Instantly share code, notes, and snippets.

@achamian
Created June 9, 2011 05:54
Show Gist options
  • Save achamian/1016138 to your computer and use it in GitHub Desktop.
Save achamian/1016138 to your computer and use it in GitHub Desktop.
Copy public key to authorized_keys
#!/usr/bin/env sh
# Copy public key to authorized_keys of a remote machine
if [ -z $1 ] || [ -z $2 ];then
echo "Usage"
echo "ssh-copy-id hostname /path/to/public/key"
exit
fi
KEYCODE=`cat $2`
ssh -q $1 "mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo "$KEYCODE" >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment