Linux Tactic

Secure Server Communications: Generating SSH Keys with PuTTYgen on Windows

Generating SSH Keys on Windows with PuTTYgen

If you’re in the IT space, or if you’re someone who works with servers, system administrators, or developers, you must have come across the term “SSH Keys” at some point in your career. An SSH key is a pair of keys: a private key and a public key that is used for authentication and encryption purposes in secure connections between machines.

In this article, you’ll learn how to generate SSH keys on Windows using PuTTYgen, which is a free and open-source SSH client for Windows.

Downloading PuTTYgen

Before you can start generating SSH keys with PuTTYgen, you need to download the tool first. PuTTYgen is freely available on the official website of the developers, and it is relatively easy to download.

Head over to the official download page at the following link: “https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html.” After downloading it, open the .exe file to begin the installation process.

Creating SSH Keys with PuTTYgen

After downloading and installing PuTTYgen, the next step involves creating an SSH key pair using the tool. Here’s what you need to do:

1.

Launch PuTTYgen from your Windows machine by searching for it in the search bar. 2.

In the “Parameters” section, select “RSA” from the “Type of key to generate” option. 3.

Next, specify the number of bits for the key; we recommend setting it to 2048 or more. 4.

Under the “Key comment” section, enter a recognizable name for your key something that you can associate with this particular key pair. 5.

Set up a passphrase for your key a passphrase is an added security measure that acts as a password to access the private key. Ensure that you choose a secure and strong passphrase.

6. After configuring all the settings, click on the “Generate” button to generate the key pair.

7. During the generation of the key pair, you need to move your mouse randomly over the screen and make it as random as possible to create a strong key.

8. Once the key pair has been generated, it’s time to save the two files: public and private keys.

For the private key, click on the “Save private key” button and give it a recognizable name like, “id_rsa”. Save the file in an appropriate location on your machine.

For the public key, select the entire public key text and copy it to the clipboard.

Copying the Public Key to the Server

Now that you’ve successfully generated your SSH key pair, it’s time to copy the public key to the remote server you’d like to connect to. Here’s what you need to do:

1.

Launch PuTTY on your windows machine. 2.

In the “Host Name” section, enter the IP address of the remote Linux server. Ensure that you use the SSH protocol for the connection.

3. Next, enter the username and the password for the remote server and click on the “Login” button to connect.

4. Once you’re logged in, open up the authorized_keys file on the server you just connected to.

This file is located in the ~/.ssh/ directory. If this file does not exist, you should create it using a text editor (for example, with the command: “nano ~/.ssh/authorized_keys”).

5. Finally, paste the public key you saved in PuTTYgen onto the authorized_keys file in the remote server terminal.

Ensure that you save it properly. 6.

Once you’ve saved the public key on the remote server, exit from PuTTY and relaunch it. 7.

In the “Saved Sessions” section, save the current session as a new session with a recognizable name that identifies the server. 8.

Click the “Open” button to initiate the connection to the remote server. The remote server will prompt for a passphrase enter the passphrase you set up for the key pair.

Conclusion

In conclusion, generating SSH keys on Windows with PuTTYgen is essential for anyone who works with servers, systems administrators, or developers. With this article, you’ve learned the different steps involved to generate an SSH key pair and copied the public key to the remote Linux server.

These steps are fundamental, and by following these guidelines, you can begin to establish secure connections between your machines. Generate these keys for any server that you manage, and be sure to save them properly for future use.

Practice good security hygiene and take steps towards better security practices.

Logging in to the Server using SSH Keys

One of the most significant advantages of SSH keys is that they eliminate the need to use a password for authentication when logging in to a remote Linux server. Not only is it faster and more convenient, but it is also more secure because it nixes brute-force attacks aimed at discovering passwords.

In this section, we will discuss how to use Pageant to hold private keys and how to log in to the remote server using SSH Keys.

Using Pageant to Hold Private Keys

PuTTY has an additional tool called ‘Pageant,’ which you can use to hold the private key temporarily during a session. This tool is necessary when you need to use a passphrase-protected private key to connect to a remote server multiple times during a session.

Pageant will prompt you to enter the passphrase only once, and then it will hold the private key for future use. Here’s how to use Pageant to hold private keys:

1.

Launch Pageant search for it in your program folder.

2.

Once Pageant is open, right-click the Pageant icon in the system tray (which is in the lower right side of the screen), and select “Add Key.”

3. Locate the private key from the desired directory and add it.

4. Once added, you will need to type in the passphrase that was configured when generating the SSH keys.

5. After entering the passphrase, Pageant will hold the private key temporarily during the session.

6. Now, open PuTTY and begin to establish a session to the remote server using the SSH key.

Logging in to the Server using SSH Keys

Once you have the private key held by Pageant, it is time to log in to the server using SSH Keys. Follow these simple steps:

1.

Launch PuTTY and select the desired saved session you want to log in to. 2.

Ensure that the username and IP address fields are correct. 3.

Under the “Category” on the left-hand side, select “Auth.”

4. Under the “Authentication parameters” section, select the checkbox next to “Allow agent forwarding.”

5.

Click on “Open,” and PuTTY will start the authentication process. 6.

If everything goes well, you will be automatically logged into the remote server through the SSH connection.

Disabling SSH Password Authentication

Once you’ve set up SSH keys for authentication on your remote server, the next step is to disable password authentication for added security purposes. Here’s how to do that:

Opening the SSH Configuration File on the Remote Server

The first step before making any changes is to access the SSH configuration file that is relevant to the operating system. To access the file, follow these steps:

1.

Log in to the remote server as a root user or a user wth root permissions. 2.

Navigate to the “sshd_config” file location its usually in the /etc/ssh directory. 3.

Open the “sshd_config” file in your preferred text editor.

Disabling SSH Password Authentication

To disable SSH password authentication, find the “PasswordAuthentication” parameter in the sshd_config file and update it to:

PasswordAuthentication no

Once the file is saved, restart the SSH service to apply the changes. The command to restart the SSH service differs depending on the system in use.

After disabling password authentication, all future logins to the remote server will require you to use an SSH key pair for authentication. Security is an essential aspect of Linux server maintenance, and disabling password authentication is an effective way to enhance protection.

Along with setting up SSH keys, you must adopt good security practices such as regularly reviewing log files, implementing access controls, firewalls, and network security protocols.

Conclusion

SSH keys are a potent tool for secure SSH communications, and it’s essential to know how to create and use them correctly when managing remote servers. With these guidelines, you should now be able to create a key pair, log in to the remote server using SSH Keys, and disable the password authentication for added security measures.

With these security measures in place, you can be confident your remote server communications will be secure. In conclusion, SSH keys are an essential tool for secure SSH communications when managing remote servers.

By following the steps outlined in this article, you can create and use SSH keys correctly, log in to the remote server using SSH Keys, and disable password authentication for added security measures. Remember, good security practices such as regularly reviewing log files, implementing access controls, firewalls, and network security protocols are necessary for enhanced protection.

Adopt these practices, and you can be confident that your remote server communications will be secure. In today’s digital world, maintaining the safety and security of your server and its data should be a top priority for any system administrator.

Popular Posts