Connect to VPS using OpenSSH key on windows

PuTTY is a famous client program for SSH in addition to Telnet and Rlogin.

PuTTY does not have native support for reading OpenSSH’s SSH-2 private key files. We use PuTTY to connect to the SSH.

However, PuTTY does have an add on named PuTTYgen which can generate RSA and DSA based keys (DSA based being less popular due to less secure than RSA).

This utility can convert OpenSSH private key files into PuTTY’s format thus you can connect to VPS using OpenSSH key on windows with the added security that SSH keys provide.

PuTTYgen is a free open-source application can be downloaded from their official website.

Just download the PuTTY and PuTTYgen so we can connect to VPS using OpenSSH key on windows platform.

Generate OpenSSH compatible Keys

To generate a set of RSA keys with PuTTYgen:

  1. Start the PuTTYgen utility, by double-clicking on its .exe file;
  2. For Type of key to generate, select SSH-2 RSA;
  3. In the Number of bits in a generated key field, specify either 2048 or 4096 (increasing the bits makes it harder to crack the key by brute-force methods);
  4. Click the Generate button;
  5. Move your mouse pointer around in the blank area of the Key section, below the progress bar (to generate some randomness) until the progress bar is full;
  6. A private/ public key pair has now been generated;
  7. In the Key comment field, enter any comment you’d like, to help you identify this key pair, later (e.g. your e-mail address; home; office; etc.) — the key comment is particularly useful in the event you end up creating more than one key pair;
  8. Optional: Type a passphrase in the Key passphrase field & re-type the same passphrase in the Confirm passphrase field (if you would like to use your keys for automated processes, however, you should not create a passphrase);
  9. Click the Save public key button & choose whatever filename you’d like (some users create a folder in their computer named my_keys);
  10. Click the Save private key button & choose whatever filename you’d like (you can save it in the same location as the public key, but it should be a location that only you can access and that you will NOT lose! If you lose your keys and have disabled username/password logins, you will no longer be able log in!);
  11. Right-click in the text field labeled Public key for pasting into OpenSSH authorized_keys file and choose Select All;
  12. Right-click again in the same text field and choose Copy.Connect to VPS using OpenSSH key on windows

NOTE: PuTTY and OpenSSH use different formats for public SSH keys. If the SSH Key you copied starts with “—- BEGIN SSH2 PUBLIC KEY …”, it is in the wrong format. Be sure to follow the instructions carefully. Your key should start with “ssh-rsa AAAA ….”

Save The Public Key On The Server

Now, you need to paste the copied public key in the file ~/.ssh/authorized_keys on your server.

    1. Log in to your destination server; see How to Log Into Your Droplet with PuTTY (for windows users)
    2. If your SSH folder does not yet exist, create it manually:
mkdir ~/.ssh
chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0644 ~/.ssh/authorized_keys
    1. Paste the SSH public key into your ~/.ssh/authorized_keys file
vi ~/.ssh/authorized_keys
  1. Tap the i key on your keyboard & right-click your mouse to paste.
  2. To save, tap the following keys on your keyboard (in this order): Esc, :, w, q, Enter.

PuTTY Profile With Server’s Settings

In PuTTY, you can create (and save) profiles for connections to your various SSH servers so the settings can be saved permanently.

  1. Start PuTTY by double-clicking its executable file;
  2. PuTTY’s initial window is the Session Category (navigate PuTTY’s various categories, along the left-hand side of the window);
  3. In the Host Name field, enter the IP address of your VPS or its fully qualified domain name (FQDN).
  4. Enter the port number in the Port field (for added security, consider changing your server’s SSH port to a non-standard port.
  5. Select SSH under Protocol;
  6. Along the left-hand side of the window, select the Data sub-category, under Connection;
  7. Specify the username that you plan on using, when logging in to the SSH server, and whose profile you’re saving, in the Auto-login username field;
  8. Expand the SSH sub-category, under Connection;
  9. Highlight the Auth sub-category and click the Browse button, on the right-hand side of the PuTTY window;
  10. Browse your file system and select your previously-created private key;
  11. Return to the Session Category and enter a name for this profile in the Saved Sessions field, e.g. user@123.456.78.9 or user@host.yourdomain.tld;
  12. Click the Save button for the Load, Save or Delete a stored session area.

Now you can go ahead and Connect to vps using OpenSSH key on windows  and you will not be prompted for a password. However, if you had set a passphrase on your public key, you will be asked to enter the passphrase at that time.

Next lets confirm the following lines are set to yes (these are normally enabled by default and may be commented out) using

vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments