What’s SSH & SSH Keys

SSH A.K.A Secure Shell is used to make remote connections between computers to execute commands. A username and password is used for the authentication purpose when establishing the connection. If you have a very strong password, it’s almost 100% secure to use SSH since the data transmission is encrypted. But are you comfortable with typing the lengthy password every time you want to SSH? Also every time you type your password, you are sending your password over the network. So anyone who is eavesdropping on your connection will be able to intercept and crack your password. But if you switch to SSH keys you haven’t got anything to worry because your password is never transmitted over the network. Check out image below to get a vivid idea about the concept. So let’s get down to business(happy-face).

SSH Tunneling

Image Courtesy : addictivetips.com

1. Create the RSA Key Pair

ssh-keygen command is used to generate a key pair. Most probably you will already have a key pair in your computer. If not type the below command.

Okay good, now you have successfully generated the key pair, so let’s store them.

2. Store the Keys and Passphrase

Once you type the above command you will be prompted with below.

You can press enter here and save the file to the user home.

I know your question and it’s already answered here(do i need to have a passphrase for my ssh rsa key).
once you proceed, you will get an output similar to the below output.

3. Copy the Public Key

Now you can copy the public key to the destination which you prefer the SSH access without a password.

Now you should get a similar output as below.

Common Problems

Below are the two key problems I have identified during configuring SSL keys. Just in case if you come across one of them or else both of them, don’t worry I got your back. Let’s fix them.

Problem 1

If you are having an issue connecting to the SSH destination make sure that the SSH destination is configured to accept private/public key authentication. To get it done edit the sshd_config file.

You should change RSAAuthenticationPubkeyAuthentication to Yes.

Make sure that the above two lines are not commented( no hash(#) sign in-front of the line). If you have to uncomment the lines don’t forget to restart the SSH server using below command.

Problem 2

You could end-up with still having to be asked for your password as shown below.

So try the ssh-add command on your computer(on client).

You will get the below output.

You are done, no more steps, no more issues. Now you have passwordless access to your preferred destination. Get to know more about SSH keys here. If you have any questions let me know in the comments below. Your feedback is highly appreciated(happy-face).

Be Sociable, Share!