SSH Login to another host without password using ssh-keygen

How To Setup SSH equivalence

If you have multiple hosts with the same user on them you can setup ssh equivalence so you can ssh from one host to another without a password.  This is also help for scp commands.

First you will need to create an ssh-key, make sure you run this as the regular user and not root

$ ssh-keygen -t rsa 

The keys just generated is placed in the users home directory



Then you will use the bash script to copy the key you just created to a remote host you would like to login to without a password.

$ ./ user@host

When you run the you will be prompted to login to the remote host with your user.

That is it, now when you ssh user@host you will not need to enter a password.

If you need a copy of the script, here are the contents which can also be found here on git


if [ ! -f ~/.ssh/ ];then
echo "private key not found at $KEY"
echo "* please create it with "ssh-keygen -t rsa" *"
echo "* to login to the remote host without a password, don't give the key you create with ssh-keygen a password! *"
if [ -z $1 ];then
echo "Please specify user@host.tld as the first switch to this script"
echo "Putting your key on $1... "
ssh -q $1 "mkdir ~/.ssh 2>/dev/null; chmod 700 ~/.ssh; echo "$KEYCODE" >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys"
echo "done!"