How do I add a password to an OpenSSH private key that was generated without a password?

Viewed 119181

I generated an OpenSSH private key using puttygen (and exported it in OpenSSH format). How can I put a password on this existing key (I know how to generate a new key with a password)?

4 Answers

Because you've mentioned "PuTTYgen" and maybe you're using Windows , I'll direct you to the documentation for "PuTTYgen".

Go here [https://the.earth.li/~sgtatham/putty/0.76/htmldoc/Chapter8.html#puttygen-conversions] for "importing" and "exporting" a SSH private key. These are different to using "Load" and "Save" as those options are for loading and saving a Putty specific key file.

And here [https://the.earth.li/~sgtatham/putty/0.76/htmldoc/Chapter8.html#puttygen-passphrase] for changing the passphrase. Same thing you'd do when creating a passphrase for a new private key.

So steps are "import" the SSH key, you don't get asked for a passphrase because you didn't create one. Then change (set) the passphrase and confirm. Then "export" back out to the original private key file.

Hope that helps anyone else wanting to use "PuTTYgen" instead of "ssh-keygen".

Related