Created
July 29, 2011 10:33
-
-
Save zeppelin/1113587 to your computer and use it in GitHub Desktop.
Upload id_dsa.pub to host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# from: http://hints.macworld.com/article.php?story=2007091814022049 | |
KEY="$HOME/.ssh/id_dsa.pub" | |
if [ ! -f ~/.ssh/id_dsa.pub ];then | |
echo "private key not found at $KEY" | |
echo "* please create it with "ssh-keygen -t dsa" *" | |
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *" | |
exit | |
fi | |
if [ -z $1 ];then | |
echo "Please specify user@host.tld as the first switch to this script" | |
exit | |
fi | |
echo "Putting your key on $1... " | |
KEYCODE=`cat $KEY` | |
ssh -q $1 "mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo "$KEYCODE" >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys" | |
echo "done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment