Created
March 26, 2015 12:47
-
-
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
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
#!/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