How to Generate SSH Keys in PuTTY for the security of your website

An SSH key is one of the most secure SSH authentication options. It is definitely more secure than the usual SSH password authentication. This is why it is recommended to use the SSH key authentication method for connections to your servers.

With password authentication, you can connect to your server from any location, you just need to enter your password. However, if your password is leaked, it is a significant risk as anyone who knows your password will be able to break into the server.

SSH key authentication only allows connections from clients whose key matches that of the server. Basically, it generates 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 you connect to the server, validation is performed on these two keys and if the key pair passes validation, you are allowed to connect. Of course, you can upload keys from multiple users so that you or other authorized users can connect to the server from different computers.

As you can see, this is a much more secure connection method. In this tutorial, we will focus on Windows users who use putty to connect to the server and we will show how to generate putty ssh keys. If you want to generate an SSH key on Linux or Mac, see .

What will you need?

Before you continue reading this guide, you will need the following:

  • Access to your Linux / VPS server
  • putty Y puttygen installed on your computer ()
See also  How to install phpBB with 's automatic installer

Step 1 – Download PuTTYgen

Although you may already have putty installed on your computer, to generate SSH keys you will also need puttygen.

  1. Download puttygen .
  1. You should be able to see this downloaded file:

It is not necessary to install PuTTYgen, it will start when the file is run.

Step 2 – Generate an SSH key pair

  1. Opens puttygen double clicking the file puttygen.exe that you have downloaded in the Step 1.
  2. You should see a window like this:
  3. Before generating your SSH key pair, you can edit some settings, for example the key length, but in most cases the default options will work just fine.
  4. Generate your pair of SSH keys by clicking the button Generate.
  5. When the progress bar starts to load, move your mouse randomly around the area to load the bar and generate your key pair.
  6. Your public SSH key will be displayed on the screen:
  7. For added security, it is highly recommended to think of a password for your SSH key (but you can also leave it empty):
  8. Save your private key anywhere on your computer and name it whatever you want.
  9. Save your public key in the same place on your computer and name it whatever you want.

And that’s it, you’ve generated your pair of SSH keys. The private SSH key will remain on your computer (don’t give it to anyone) while the public key must be uploaded to the server you want to connect to.

Step 3 – Configure your private key in PuTTY

In order for the server to recognize when your computer connects from putty, you must attach the private key to putty.

  1. Opens putty.
  2. go to Connection -> SSH -> Auth in the left sidebar.
  3. Find your private key file in the field Private Key for authentication.
  4. Select the private key file with completion .ppk and click Open.
See also  How to Use Facebook Debugger to Fix Your WordPress Images and Links

Step 4 – Add your public key on the server

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

  1. On your computer, open the public key file (id_rsa.pub) that you generated in the Step 2 with any text editor and copy its content (public key).
  2. Connect to your VPS using Putty. Please refer to the detailed steps.
  3. If the folder .ssh does not exist, create it together with the file authorized_keys with the following command:
    mkdir ~/.ssh | touch ~/.ssh/authorized_keys
  4. Secure the SSH key file by changing the permissions:
    chmod 0700 ~/.ssh; chmod 0644 ~/.ssh/authorized_keys
  5. Opens authorized_keys with the text editor vim:
    vim ~/.ssh/authorized_keys
  6. press the key Yo on your keyboard and the right mouse button to paste the public key.
  7. Press the button esc and writes 😡press Enter. This command will save the changes made to the file.

That’s it, now you can use SSH keys instead of SSH password authentication to connect to your VPS.

conclusion

You have learned how to generate an SSH key for PuTTY using PuTTYgen. This will make your connection to the server much more secure and convenient, since you won’t need to enter the password every time.

We recommend using this form of SSH authentication at all times and disabling password authentication to fully secure your server. To find out how to completely disable SSH password authentication on your server and use SSH key authentication instead, follow this tutorial:

Gustavo is passionate about creating websites. He focuses on the application of SEO strategies at for Spain and Latin America, as well as the creation of high-level content. When he is not applying new WordPress tricks you can find him playing the guitar, traveling or taking an online course.

Loading Facebook Comments ...
Loading Disqus Comments ...