Skip to content

Instantly share code, notes, and snippets.

Created March 26, 2015 12:47
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
SSH Register Server: send your local public key to the remote server so you don't have to type the password avery time
#!/bin/bash
if [ ! -f ~/.ssh/id_rsa.pub ]; then
ssh-keygen
fi
echo "Server host:"
read SRV
echo "User on the server host:"
read USR
ssh $USR@$SRV 'mkdir .ssh; chmod 700 .ssh; touch .ssh/authorized_keys2; chmod 640 .ssh/authorized_keys2'
cat ~/.ssh/id_rsa.pub |ssh $USR@$SRV 'cat >> .ssh/authorized_keys2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment