Public Key Authentication for SSH


No Category

Public Key Authentication for SSH allows users to not need to enter the password when calling ssh related commands.

This tutorial shows in a few lines on how to configure the Public Key Authentication for SSH access.

What is Public Key Authentication for SSH?

Public key authentication is a method of SSH authentication that relies on a pair of cryptographic keys to identify the client to the server. The keys, known as the private key and the public key, are generated on the client and are used to encrypt and decrypt data sent between the client and the server.

In public key authentication, the private key is kept on the client and is used to encrypt data sent to the server. The corresponding public key is stored on the server, and is used to decrypt data received from the client. When the client attempts to log in to the server, the server uses the public key to encrypt a challenge that it sends back to the client. The client then uses the private key to decrypt the challenge and respond. If the client’s response matches the expected response, the server grants the client access.

Public key authentication is considered to be more secure than password-based authentication because the private key is difficult to guess or crack, and because the encryption and decryption process used in public key authentication provides strong protection against eavesdropping and tampering.

Generating and Uploading SSH Key

First and foremost, you should generate an SSH key if you have not yet. You can do it by checking if the files ~/.ssh/id_rsa and ~/.ssh/ exist.

If not, you can run the following command to generate it:

$ sssh-keygen -b 4096

Press Enter when asked a location to save your public key which will save the keys at ~/.ssh/.

Now that you have generated the SSH key, it should be uploaded to the server where you want the key to be. Please follow these steps:


You will be asked for your server password. Once this is done, you should be good to go.

In conclusion, this tutorial was short and sweet. There are many other methods to do the same thing such as using scp to copy the keys into the server, or even manually copy and create the keys into the server. I hope this works for you!

Related Posts