4 min read May 2, 2017 at 2:17pm
PuTTY includes PuTTYgen, a key generator program. PuTTYgen is essentially the
ssh-keygen command but with a graphical interface. The process to create key pairs using PuTTYgen requires multiple stages, but it is not difficult to follow.
1) Press “Windows Logo Key” (Win) plus “Q” to open the Search menu. Type PuTTYgen and click on its icon.
2) Then, select “RSA” as the type of key to generate and press the “Generate” button.
3) Move your mouse around the blank area to help PuTTYgen produce key pairs that are harder to decipher. Once this process is finished, PuTTYgen gives you the key ready to be pasted into the
.ssh directory of your VPS, as shown in the next screenshot.
4) To facilitate administrative tasks, substitute what is inside the “Key comment” field for your email. Leave both “Key passphrase” and “Confirm passphrase” fields empty. Then, click on “Save private key.” If PuTTYgen asks you to confirm the action, say yes.
5) Now save the key in a folder of your preference. As that key will only be used to access one single machine (and it is an important detail why passwords are not used here), give it a name that evokes your VPS easily.
6) Click on the key box. Press “Control” + “A” to select everything inside this field, that is, to select all the key content. After that, press “Control” + “C” to copy its content.
7) Press “Win” + “Q” to expose the Search menu and type PuTTY. Click on the PuTTY icon to open it. In the “Host Name” area, write the IP address of your virtual private server1. Certify that “SSH” is the option selected in the “Connection Type” field and the port is 22.
8) In the “Load, save or delete a stored session” area, save the session with the hostname of your server by writing its name in the field specified below. Click on “Save” to confirm your action.
9) Next click “Open” to create a connection. If it is the first time you are accessing your server on your local machine, PuTTY alerts you that “the server’s is not cached in the registry.” Just click “Okay” to confirm the trustfulness of your server.
10) At that point, the PuTTY’s terminal windows asks you how you would like to log in to the system. Insert your username; if
root is the only user available, write
root and press Enter to continue. The password is still required for the last time in this process. Thus, type it and press Enter again.
11) As soon as you are logged in to your virtual private server, make sure you are in the right user directory; you can perform it by using the
pwd command. If you are not sure about it, use the
cd command without arguments to be redirected to your user directory. It is also important to examine whether the
.ssh directory already exists or not. Use the
ls -A command to look for the
.ssh directory carefully.
12) In the case of this guide, the
.ssh directory already exists. If you need to create it, use the following command:
13) The next step requires special attention. The
echo command is used to redirect the key content into the
.ssh/authorized_keys file. To perform it, type
echo, then double quotes and right-click on the terminal to copy the key content. Subsequently, close the double quotes. Use the
>> operator to append the echo output to the
.ssh/authorized_keys file. Press Enter to continue. The following screenshot can clarify that process.
14) Now log out of the server by using the
exit command and close PuTTYgen window if it is still opened.
15) In Step 5, you saved the key in a folder of your preference. Go there and open the key to make it available to PuTTY. You should see the keys' icon in your system tray.
16) Open PuTTY again. Select the section of your server that was saved in Step 8 and click “Open.” Now, just type your username and press Enter.
The entire process is finished. Now you can easily log in to your virtual private server without using passwords.
1 Here you can also specify the username; it saves you the time of typing the username in the terminal window. The formula to perform it is
[user@]hostname. For example, if your user is
diego, insert in the “Host Name” field
firstname.lastname@example.org. In this guide, however,
root is the only user available; the same occurs if it is the first time you are connecting to your server. In that situation, it is preferable to just insert the IP address. Since the goal here is to connect to your server without password, typing the user works as a reminder that you are accessing as
written by Diego Aurino.