SSH with authentication files

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
Advertisements

One thought on “SSH with authentication files

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s