Puttygen is used to generate ssh public and private keys for putty. We can use different type of encryption algorithms bit sizes and ssh versions. In this tutorial we will look useful examples of puttygen.
puttykeygen is provided with putty packages most of the Linux distributions like Ubuntu, Debian, Fedora, CentOS, RedHat.
$ apt install putty
Fedora, CentOS, RedHat
$ yum install putty
Windows binaries are provided with the following url.
Syntax of puttygen is like below.
puttygen KEYFILE OPTINONS
KEYFILEis the file we read
OPTIONSare used to specify size, output keyfile etc.
Create Key with Default Options
We can generate keys with the following command. In this example we will generate RSA type key file named
ppk is the extension of the putty keys.
$ puttygen -t rsa -o test.ppk
Set Key Size
We have the option to set the size of the putty key. More in size means more secure but less performance. But the performance loss is negligible. We can set the size with
-b option. We will provide size as bit unit. In this example we will set the key file size
4096 bit .
$ puttygen -t rsa -b 4096 -o test.ppk
Keys are protected with symmetric encryption. This means
ppk keys are encrypted and we need to use passphrase. We can also change the current passphrase with
-P option. In order to change existing passphrase we should provide old passphrase too.
$ puttygen mykey.ppk -P
Set Comment To Key
In enterprise environment we may have multiple keys where we can not remember actually what it was. Or we may need to put some comment about keys on the key file. We can use –
C and the comment we want to set.
$ puttygen mykey.ppk -C "My key"