-
-
Save gadelkareem/c69bd844f8bb49d8b9ccac367d80b6b3 to your computer and use it in GitHub Desktop.
Revisions
-
Daniel Hansson revised this gist
Jan 31, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ if [ -n "$host" ]; then if [ -f ~/.ssh/id_rsa.pub ]; then echo "RSA public key OK." else ssh-keygen -b 4096 -f ~/.ssh/id_rsa -N "" fi echo "Appending your RSA public key to the server's authorized_keys" -
sbleon created this gist
Feb 19, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ #!/bin/bash # make sure to run this with /bin/bash, NOT /bin/sh echo echo This script will help you setup ssh public key authentication. host=dummy port=22 while [ -n "$host" ]; do echo -n "SSH server: " read host if [ -n "$host" ]; then echo -n "user[$USER]: " read usr #If user not provided use current user if [ -z "$usr" ]; then usr=$USER fi echo -n "port[$port] " read port if [ -z "$port" ]; then port=22 fi echo "Setting up RSA authentication for ${usr}@${host} (port $port)..." if [ -f ~/.ssh/id_rsa.pub ]; then echo "RSA public key OK." else ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" fi echo "Appending your RSA public key to the server's authorized_keys" scp -P $port ~/.ssh/id_rsa.pub ${usr}@${host}:~/ # Append public key to authorized keys and fix common # permission problems, eg. a group-writable .ssh dir, # or authorized_keys being readable by others. ssh ${usr}@${host} -p $port "if [ ! -d ~/.ssh ]; then mkdir ~/.ssh fi chmod 700 ~/.ssh cat ~/id_rsa.pub >> ~/.ssh/authorized_keys chmod 0600 ~/.ssh/authorized_keys rm ~/id_rsa.pub" echo echo "You should see the following message without being prompted for anything now..." echo ssh ${usr}@${host} -p $port "echo !!! Congratulations, you are now logged in as ${usr}@${host} !!!" echo echo "If you were prompted, public key authentication could not be configured..." echo echo "Enter a blank servername when done." echo fi done echo "End of configuration."