Last active
August 29, 2015 13:57
-
-
Save ianhomer/9444337 to your computer and use it in GitHub Desktop.
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
# Create SSH key - alternative to ssh-copy-id | |
export USER=me | |
export HOST=myhost.com | |
if [ ! -f ~/.ssh/${USER}_rsa ] ; then echo "Creating SSH key" ; ssh-keygen -t rsa -f ~/.ssh/${USER}_rsa -C "${USER} access" ; fi | |
cat ~/.ssh/${USER}_rsa.pub | ssh $USER@$HOST 'mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat - >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys' | |
cat >> ~/.ssh/config << EOF | |
Host $HOST | |
HostName $HOST | |
User $USER | |
IdentityFile ~/.ssh/${USER}_rsa | |
EOF | |
# Then log in with | |
ssh $HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment