Subscribe via

The Simple Explaination and Use of SSH keys

What are SSH Keys? (Easier than what you learned in Computer Security class)

SSH keys are one of the common authentication techniques people use to log into a Unix session (the most common authentication technique is login & password).

If you are like me, you get sick and tired of typing in your login and password every single time you open a new terminal to connect to a Unix session. This is where SSH keys help me everyday by letting me authenticate against the key once, and every new shell session I start will authenticate using the same SSH key.

All you have to do is create a pair of public and private keys. In this analogy, the public key is the house lock and the private key is equivalent to the house key.

Private Key = House key

Public Key = House locks

Using an SSH key to authenticate is like using one key for all the doors in your house instead of having a bunch of combination padlocks (with the same unlock combination) on all your doors.

How to Setup SSH Key Authentication (using OpenSSH)

  1. Run ssh-keygen and follow prompt (# ssh-keygen -t rsa -b 2048)
  2. Save the key as id_rsa under your ~/.ssh/ directory
  3. Create a password for the key pair
  4. You will get two files:
    1. id_rsa (this is your private key)
    2. id_rsa.pub (this is your public key)
  5. Log into your desired machine (using login & password this time)
  6. Append the contents of your local id_rsa.pub into the machine’s ~/.ssh/authorized_keys
  7. Log out
  8. Log back in and you should notice that you will not need to type the username and password anymore
  9. Repeat this with any other number of machines you log into often
Save and Share
StumbleUpon
Reddit

One Response to “The Simple Explaination and Use of SSH keys”

[go to last comment]
  1. How to Encrypt Your Internet Traffic | OMNINOGGIN

    […] password-less login, you can setup SSH key authentication but this is […]

[go to first comment]