Automatic login for SSH

I often have to use remote computers for part of my work.  Since this is on Linux machines, the easiest way to do this is to use SSH - a Secure SHell connection.  I can log in, do my work and then log out again.  Files can be copied with scp.

However, every time I log in I'm required to enter my password for authentication.  This is clearly a good thing, except that it gets quite tiresome when you have to do it often.  There's a way to bypass this, while maintaing the same level of security.

When you log in using SSH (or transfer files with scp) the 2 computers exchange their public keys with each other, so that they can transfer encrypted data with each other.  In order to avoid having to enter your password, what you need to do is to store the computer's public key on your computer.  This will work for as long as the public key remains the same (some system administrators may alter the public key every now and then as a security measure, but you just need to repeat this process to get the new key).

 - First, log in to the remote machine (using your password).

 - Next, we need to create the public key:

ssh-keygen -t rsa

 - You will be asked for a file in which to save the key, and a passphrase to use.  Select the defaults (~/.ssh/id_rsa and empty, respectively).

 - Append the new key to the end of the authorized_keys file with the following command:

cat id_rsa.pub >> authorized_keys

 - Now go back to your local machine and enter the ~/.ssh directory (creating it if necessary).

 - Copy the file that was created on the remote machine to this directory (I used scp):

rob@remote-machine:~/.ssh > scp id_rsa rob@192.168.16.79:/home/rob/.ssh

 - And that's it - you can now login without a password!