How to generate SSH key for Windows machine

If you are using Windows operating system on your local machine, then you can use SSH terminal application such as putty which is available at http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html

If you are using Windows 10 or later version, you may directly generate SSH key from your terminal. However, putty may also work on Windows 10, thus helping as universal ssh terminal for Windows machine.

Once you have downloaded Putty, Open PuTTYgen.

Under Parameters specify the following:

  • Type of key to generate: RSA
  • Number of bits in a generated key: 2048 or more

Click Generate and follow the on-screen instructions.

The tool displays the public key value.

In the Key comment section, replace the pre-populated text with your username. For example, johnssh, or johnssh_xxxx_com.

Hit enter for Key passphrase to remain as none.

Click Save private key to choose a location to save the private key to.

PuTTYgen writes the private key to a file with a .ppk extension.

Click Save public key to choose a location to save your public key to. Keep the PuTTYgen window open.

Copy the text from the Public key for pasting into OpenSSH authorized_keys file field.

Open the public key file. The public key has a format similar to the following:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "johnssh"
KEY_VALUE
---- END SSH2 PUBLIC KEY ----

Replace the entire contents of the public key file with the value you copied from the Public key for pasting into OpenSSH authorized_keys file field, so that your public key file matches the following format:

KEY_VALUE johnssh

A public key for the user johnssh looks similar to the following:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAu5kKQCPF... johnssh

You will now need to add above key to your remote SSH authorized_keys file which is usually located under /root/.ssh