Using SSH without password

Using SSH often to login to remote systems? Sick of entering your password every few minutes? Consider logging using public key authentication.

What is this?

This authentication method uses 2 keys: private and public. Let’s use example:

  • S is some remote server
  • C is your laptop

The public key is put on server. It can be shared with anyone, it is of no use to anyone except the owner of the private key.

The private key is kept in safe place on laptop. During authentication server S verifies whether the secret key from C matches the public key on S. If so, user is allowed to log in. It is important to remember, keeping the private key secret is just as important as guarding your password.

Preparation

Simpler than it used to be… To generate the new key pair:

and follow defaults. There will be a warning if the key already exists. For simplicity don’t specify a password (I will write how to use a password protected key without having to type too much another time).

Now, to copy the public key to remote sever run:

Enter the password once more, and try:

Congratulations! And remember to protect the key!