-
-
Save hyfather/1016537 to your computer and use it in GitHub Desktop.
Copy public key to authorized_keys
This file contains hidden or 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
#!/usr/bin/env sh | |
# Copy public key to authorized_keys of a remote machine | |
if [ -z $1 ];then | |
echo "Usage" | |
echo "ssh-copy-id hostname /path/to/public/key" | |
exit | |
fi | |
if [ -z $2 ]; then | |
KEYCODE=`ssh-add -L` | |
else | |
KEYCODE=`cat $2` | |
fi | |
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