Setting up SSH key on a remote server using PuTTy (Windows)

Apeksh Agarwal
4 min readSep 15, 2022

Hello everyone. In this blog, I will demonstrate how to configure an SSH key on a remote server using PuTTy from Windows and how you can also get .pem file from .ppk file in optional section.

So let's get started without any further delay.

Pre-Requisites:

  • PuTTY SSH client for Microsoft Windows
  • Remote server accessible over OpenSSH

💎 Steps:

  1. Generate a key pair using PuTTy Key Gen: Open PuTTygen from applications and click on Generate to produce a key pair. After a key is generated it will look like shown below.
    Note: Copy the public key displayed as it will be later used.

2. Save the private key: Save the private key in your local system by clicking on Save private key. You can also enter a key passphrase to secure it. It will be saved in ppk format.

3. Get the public key: If you did not copy the public key earlier shown then you can get the public key from the earlier saved ppk file. Press right click on it and then Edit with PuTTygen and now copy it somehere.

4. Store the pubic key on remote server: Now go to your user directory and paste the key in ~/.ssh/authorized_keys file by using your editor.

If the above directory structure is not present then create it manually.

# If the .ssh directory structure not present, then execute these commands
$ cd ~
$ mkdir .ssh
# paste the key using your editor (below vim is used)
$ vim .ssh/authorized_keys

5. Change the permissions: To be able to use the ssh key we need to change permissions for .ssh directory and files under it. Execute below commands.

  • chmod 700 ~/.ssh
  • chmod 600 ~/.ssh/authorized_keys
  • chown $USER:$USER ~/.ssh -R

That’s it. Now you can easily log into your server using your private key using PuTTy.

✨ Connect To Server With Private Key:

  1. Enter the remote server Host Name or IP address under Session.

2. Navigate to Connection > SSH > Auth.

3. Click Browse... under Authentication parameters / Private key file for authentication.

4. Locate the private key file .ppk and click Open.

5. Finally, click Open again to log into the remote server with key pair authentication.

👀 (Optional) Getting .pem file from .ppk file:

  1. Open the ppk file with option Edit with PuTTygen by pressing right click on it.
  2. Select Export OpenSSH Key under Conversions tab menu at the top and then save the file with your desired extension like .pem.

3. Modify the permissions of new file from open to private. In windows go to properties and then choose advanced settings under Security tab and then disable inheritance and allow the only the current user to access it.

4. Connect to server using key

So that’s it, folks for, this blog. I hope you guys liked it. See you in the next blog. Till then keep learning.

--

--