Skip to content

Instantly share code, notes, and snippets.

@r10r
Last active December 14, 2015 14:39
Show Gist options
  • Save r10r/5102032 to your computer and use it in GitHub Desktop.
Save r10r/5102032 to your computer and use it in GitHub Desktop.
Authorize one or more public keys.
#!/bin/bash
# usage: cat $HOME/.ssh/id_dsa.pub | $0 foo@bar.com
PUBLIC_KEY=`cat`
echo "-- Adding public key(s) to account: $@ --"
echo "$PUBLIC_KEY"
ssh -T $@ <<EOF
[ -d \$HOME/.ssh ] || mkdir \$HOME/.ssh
echo "$PUBLIC_KEY" >> \$HOME/.ssh/authorized_keys
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment