Often, if you want to use SSH to connect to some host, you will use it like this:

$ssh username@some.host.com

Then it will prompt you to input your password, after type in the password, you are now on the server.

But it will be annoying to have to input password every time when you login. However, SSH does provide some mechanism to avoid this.

You need to use a “key” to do this. First you generate a public key and private key, in which public key is sent to some one in advance to notify that “this is my lock”. And then when you tried to connect to the server, the server found your “lock” at its own repository, it will ask you for the “key”, which is the private key in this case. You ssh client will send the private key to the server, and the server get the key and tried it on the “lock”, A-HAH, they match ! So now you are logged in, don’t need any password.

Here’s the exact command to do this:

  • First on your own machine, generate the key/lock files:
    • $ ssh-keygen –t RSA

this command will generate two files, one is the “lock” which name is id_rsa.pub; the other is the “key” which name is “id_rsa”

  • Then send the lock to the server: append the content of the “lock” file to the server’s configuration file. Often

    this file located in the directory ~/.ssh. For example, if you want to login to the server with name “Admin”, you can copy the “id_rsa.pub” file into the server’s directory “/home/Admin/.ssh”, and then execute this command:

    • cat id_rsa.pub >>authorized_keys

After this two simple process, now you can connect to remote SSH server without using password.

This is just for my information.