Skip to content

Instantly share code, notes, and snippets.

Created March 26, 2015 12:47
Show Gist options
  • Save anonymous/be7b6000497dd435b9cc to your computer and use it in GitHub Desktop.
Save anonymous/be7b6000497dd435b9cc to your computer and use it in GitHub Desktop.
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