Update: For the impatient people:
ssh-keygen -t rsa && ssh-copy-id -i ~/.ssh/id_rsa.pub
It’s handy to log into our machine, and then to be able to access all machines of our network (or even remote machines) via SSH, without having to enter the password each time. We can avoid manual authentication generating an authentication key in our machine, and then adding that key to the list of authorized keys in remote machines.
Of course this give to our computer a strong power: we need to have extra care in its protection…
Generally speaking this is a two step procedure:
STEP1: generate your authentication key
$ ssh-keygen -b 2048 -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/utente/.ssh/id_rsa): (hit ENTER) Created directory '/home/utente/.ssh Your identification has been saved in /home/utente/.ssh/id_rsa. Your public key has been saved in /home/utente/.ssh/id_rsa.pub. The key fingerprint is: 90:98:4f:f5:69:39:57:5d:46:83:a4:a2:d6:63:3c:25
STEP2: import your auth file in the remote server
Then you have to append into the authorized_keys file (it’s in your .ssh directory) the file you just created locally.
First scp the file to your remote home, then append it… easy?
$ scp ~/.ssh/id_rsa.pub user@remotehost $ ssh user@remotehost $ cat id_rsa.pub >> .ssh/authorized_keys $ rm id_rsa.pub