How to Connect to SSH with Private Key

There is more than just one way to establish an SSH connection, today we will show you how to do so using a private key.

Updated: 14 Dec, 21 by Susith Nonis 4 Min

The majority of servers on the internet are run on Linux, meaning if you want to connect to them, you have to use SSH (Secure Shell), a remote administration protocol that allows you to control and modify your remote servers over the internet.

If you are connecting from a Linux OS or macOS, typically, you would open the terminal and enter ssh [user]@

Web Hosting
Web Hosting

Starting From $6.99/Monthly

which would then prompt you to enter the password for the user.  In this case, [user] represents the account you want to access, for example, root, and the
Web Hosting
Web Hosting

Starting From $6.99/Monthly

represents the server you wish to access, which can be either an IP address or a domain name.

Windows users, on the other hand, have to download an SSH client such as PuTTY to establish an SSH connection. Within the client, they have to enter the server IP and the SSH port. Afterward, a window will open that will ask you to enter the username followed by the password.

There is, however, another way you could establish an SSH connection without using the username and password. You can connect to SSH with a private key, and today we will show you how it’s done.


How to connect to a Linux server with an SSH private key using PuTTY

First, you will need to install some software on your machine:

  • PuTTY
  • PuTTYgen

We recommend using the PuTTY client to connect to SSH from Windows (these steps can also be done on Linux and macOS as both PuTTY and PuTTYgen are also available on said OS). Both can be installed from the official site with only one installer. Once the software is installed, you are ready to begin the setup.

  1. Create a text file, paste your SSH private key into it, and save the file. This type of file is called a key file. Do keep in mind that you must also include the BEGIN and END It should look similar to this:

  1. Launch PuTTY Key Generator (i.e. PuTTYgen)
  2. Within the Actions menu, click on Load, and select the key file that you created in step 1. If the key is loaded successfully, a confirmation should be displayed. Click on OK to dismiss the message.

  1. Enter a unique key passphrase into the Key passphrase field and then re-enter it again into the Confirm passphrase You will be prompted for the passphrase whenever you try to connect to the server using the private key (you can also leave them blank, however, it is not recommended)
  2. Now click on Save private key and enter the file name to be saved as a .ppk file.
  3. You can now close PuTTYgen and open PuTTY itself.
  4. Enter the server’s IP address into the Host Name (or IP address) field and the corresponding port into the Port Do not forget to select SSH under Connection type. Lastly, enter the name for the session under Saved Sessions and click on Save.

  1. Within the left navigation pane, click on Connection > Data and type root in the Auto-login username If you wish to access a different user, enter that user instead.

  1. Go back to the left navigation pane and click on Connection > SSH > Auth. You will see the options that control the SSH authentication. Under the Private key file for authentication click on the Browse… file button and select your .ppk file generated in step 5.

  1. Return to the starting page by clicking Session in the left navigation pane and click on
  2. Click on Open and establish your connection to the server.

And that is how you set up an SSH connection to a Linux server via the SSH private key. Since we named and saved the connection  (steps 7 and 10, respectively), we can now choose it from the saved sessions list at any time and use it without having to repeat all of these steps. If you found this tutorial useful or need some help, we encourage you to leave a comment on the article.

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.