DED9

How to Use Putty to Generate SSH Key Pairs for Security?

If you want to establish a more secure SSH connection with your server, SSH keys are one of the best options. This method is much more secure than connecting to the server with a normal password. Therefore, using the SSH key authentication method is highly recommended to connect to your servers.

With normal authentication, i.e., password only, you can connect to your server from anywhere and

with any device. Just enter your password. But if your password is leaked, it is very dangerous because anyone who knows your password can log into the server.

But if you have an SSH key enabled, even if hackers get your password, they still can’t connect to your server.

What is SSH key authentication?

 

SSH key authentication only allows connections to clients whose key matches the key on the server. Suppose, you have a pair of keys (private key and public key). The private key is placed on your local machine, and the public key is uploaded to the server. When connecting to the server, the two keys are validated and if they pass the key pair validation, you are allowed to connect.

As a result, this method is much safer than normal. In this tutorial, we will show how to generate SSH keys using PuTTY software in the Windows environment.

 

What you need to continue this tutorial:

1. Download PuTTYgen

 

Assuming that most of you have PuTTY software installed on your system, we will only teach you how to install PuTTYgen.

1. Download PuTTYgrn from here. (according to the picture below)

2. After downloading, you should see such a file in your download path:

Note that this file is executable and does not need to be installed.

2. Create SSH key pair

1. Run the executable file that we downloaded in the previous step by double clicking. You should see a window like this:

2. Before generating your SSH key, you can edit some settings, for example, key length. You can now generate your SSH key by clicking the Generate button.

3. Then your public SSH key will be displayed on the following page:

4. For added security, it is highly recommended to include a passphrase for your SSH key (you can also leave it blank):

5. Save your private key anywhere on your computer and name it whatever you like.

6. Save your public SSH key in the same place on your computer as in the previous step.

Okay; Now we have created both private and public SSH keys. Be careful not to share the private key with anyone. Also upload and set the public key on the server you want to connect to.

3. Setting the private key in PuTTY software

 

For the server to recognize you when connecting from PuTTY, you need to connect the private key to PuTTY.

1. Open the PuTTY software.

2. In the left tree menu, go to Connection -> SSH -> Auth.

3. Enter the private key file you saved in your system in the previous step in the Private key for authentication field.

[highlight color=” yellow”]Note that upload the file with .ppk extension.[/highlight]

4. Add the public SSH key to the server

Finally, you need to upload your public key to the server:

1. On your computer, open the public key file (id_rsa.pub) you created in step 2 with any text editor and copy its contents (public key).

2. Now connect to your server or VPS with PuTTY software. (Training to connect to a virtual server with PuTTY)

3. If there is no .ssh folder on your server, create it along with the authorized_keys file with the following command:

mkdir ~/.ssh | touch ~ / .ssh / authorized_keys

4. Secure the SSH key file by changing permissions:

chmod 0700 ~/.ssh; chmod 0644 ~/.ssh/authorized_keys

5. Open the authorized_keys file with vim text editor:

vim ~/.ssh/authorized_keys

6. Press the i button on the keyboard and the right mouse button to paste the public key here.

7. Press the Esc key and type :x, press the Enter key. This will save the changes made to the file.

 

it is finished. You can now use SSH keys instead of SSH password authentication to connect to your VPS.

conclusion

You learned how to generate SSH keys using PuTTYgen. This makes your connection to the server much more secure and convenient. We recommend that you always use this SSH authentication method.

Die mobile Version verlassen