SSH automatic login assistance script

The script automatically pushes your SSH private key to the server specified so you can have automatic SSH,scp and sftp authentication. If you don’t have a key the script will generate one for you, also this script assumes that the user running the script has a home directory on the remote host. Should note that this script will only push the RSA encrypted key.

The Script




# say: ./ hostname

# Uploads your to the specified host, wrapped for readability

if [ ! -r ${HOME}/.ssh/ ];then

ssh-keygen -b 2048 -t rsa


# Append to the copy on the remote server

cat ~/.ssh/ | ssh ${USER}@$1 “cat – >> .ssh/authorized_keys”

if [ $? -eq 0 ]; then

echo “Success”


save the script say as and execute it ./ hostname

Leave a Reply

Your email address will not be published. Required fields are marked *