Remote access to Linux servers via SSH is a very common practice. To carry out this access, keys are usually used instead of passwords, all with the aim of achieving greater security. When generating these keys, ssh-keygen is usually used on Linux or Mac, but in the case of Windows, the most common is to use the free tool PuttyGen, a graphical application that allows the generation of SSH keys in a simple way.
The problem when generating public keys with PuttyGen is that they are not compatible with Linux servers, as they are exported in ssh2 format. Fortunately, it is easy to generate compatible public keys as we will explain below.
What is PuttyGen?
PuttyGen is a tool that allows you to generate public and private SSH key pairs. It is an open source application, and although it was originally created for Windows systems, it is now also available for macOS and Linux. In the Windows version, a graphical interface is used, while the Linux version is command line based.
By means of PuttyGen, it is possible to create different types of public keys, among which are Rivest-Shamir-Adleman (RSA), Digital Signature Algorithm (DSA), Elliptic Curve Digital Signature Algorithm (ECDSA) and Edwards-curve Digital Signature Algorithm (EdDSA).
Finally, PuttyGen collects keys in their native format, i.e. .ppk files, although keys can be easily converted to any other format.
How to generate a public key in ssh-rsa format compatible with OpenSSH Server
Let’s see how to generate these OpenSSH-compatible keys from PuttyGen. To do this, it will be necessary to generate an RSA key, being important to make sure that we use 2048 bits for this to guarantee the best possible security.
To generate this key, we must select the type in the window that will appear when we start PuttyGen and click on the “Generate” button. The software will ask us to move the mouse to generate it.

Once the process is complete, the window will display the public key in ssh-rsa format, a format that is supported by the OpenSSH server.

The next step is to copy the key that appears in the text box and that has the correct format. This key will be saved in a text file, which will be the one we have to give to the system administrator so that he/she can allow access to the server via SSH.

As we have seen, generating the public key is very easy with PuttyGen. In a few steps we can have it ready to be used.