Skip to content

Instantly share code, notes, and snippets.

@kch
Created January 4, 2010 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kch/268764 to your computer and use it in GitHub Desktop.
Save kch/268764 to your computer and use it in GitHub Desktop.
puts your ssh public key(s) on a remote server in a single command without fuss
#!/usr/bin/env bash
if [ $# -lt 1 ]; then
echo "Usage: `basename $0` <destination_ssh_connection_arguments>"
echo "Adds your public keys to a remote server."
exit
fi
ssh $@ "
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
echo '$(cat ~/.ssh/id_*sa.pub)' >> ~/.ssh/authorized_keys
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment