SSH with authentication files

Update: For the impatient people:

ssh-keygen -t rsa && ssh-copy-id -i ~/.ssh/

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/
The key fingerprint is:

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/ user@remotehost
$ ssh user@remotehost
$ cat >> .ssh/authorized_keys
$ rm