Password-less Login Using SSH

Consider we want to login from a MacBook Pro (mbp) to a remote Linux machine (tsingyi), where both computers have OpenSSH installed. In order to make tsingyi trust mbp, we use RSA cryptographic method to generate a public and a private key for mbp, which will be used to identify mbp during login.

To generate the pair of keys, on mbp, type

ssh-keygen -t rsa

Accept all default answers, and we get two files:

~/.ssh/id_rsa     --- the private key
~/.ssh/ --- the public key

Now, copy the public key file to tsingyi by typing following command on mbp:

scp ~/.ssh/ wyi@tsingyi:/home/wyi/.ssh/

and add the public key of mbp to ~/.ssh/authorized_keys of tsingyi by typing following command on tsingyi:

cat ~/.ssh/ >> ~/.ssh/authorized_keys

Here we are. We should be able to ssh to tsingyi from mbp without typing password now.