Last active
August 29, 2015 14:00
-
-
Save amercier/68c00638299adb362220 to your computer and use it in GitHub Desktop.
bash <(curl -# -L https://gist.github.com/amercier/68c00638299adb362220/raw) <host>
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 bash | |
if [ "$1" == "" ]; then | |
echo "Syntax: $0 HOST" >&2 | |
exit 1 | |
fi | |
if [ ! -e ~/.ssh/id_rsa.pub ]; then | |
echo "Generating private/public keys..." | |
ssh-keygen -t rsa || exit 1 | |
else | |
echo "Found public key ~/.ssh/id_rsa.pub, no need to generate it" | |
fi | |
echo "Sharing public key with $1..." | |
ssh "$1" mkdir -p .ssh \ | |
&& cat ~/.ssh/id_rsa.pub | ssh "$1" 'cat >> .ssh/authorized_keys' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment