ssh public/private key using ssh-keygen

me@connect-from-machine:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/me/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/me/.ssh/id_rsa.
Your public key has been saved in /home/me/.ssh/id_rsa.pub.
The key fingerprint is:
blah blah ….

The command ssh-keygen -t rsa initiated the creation of the key pair.

The private key was saved in .ssh/id_rsa. The file is read only by you and you can see why since if someone else get it he can try to use it to connect to the same machine. If you happen to make it passphrase free, it will be even easier for the other person.

The public key is save in .ssh/id_rsa.pub.
Its content is then copied in file .ssh/authorized_keys of the system you wish to SSH to without being prompted for a password. Using scp, this can be done by scp .ssh/id_rsa.pub username@remote-machine:/.ssh/authorized_keys .

Once the file is copied you are on ssh private key login.

This entry was posted in linux goodies. Bookmark the permalink.