Changing the passphrase of a puttygen private key in Windows

I have a private key in Windows, created by puttygen.exe. I used default options to save it, the tool automatically gave it a .ppk extension, and it looks like this:

PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: rsa-key-20130627
Public-Lines: 4
AAAAB3NzaC1yc2EAAAABJQAAAIBnvvAhyMs4rdlQd4OdajDw4jIPi6vIjrWjt4l4
5C3wHOSxyQQdtSA8XT3K0rSBnNtZRJTb5mfix67qQe3pHCTMSNsYIaBi8xQJHZRa
RxdY+1VtGnSlEma8KO2We9eDNCGiwrRTUzqvTiGCnzU0pF1MXxu3ObISJcpqv+sQ
1GB0cw==
Private-Lines: 8
AAAA..........
Private-MAC: XXXXXXXXX

Now I need to change the passphrase, and according to the docs this seemed simple enough:

puttygen.exe -P key.ppk

But this pops up a window with this error:

PuTTYgen Error: Couldn't load private key (unable to open file)

I also tried to change the passphrase using ssh-keygen that comes with Git Bash:

ssh-keygen.exe -p -f key.ppk

It asks for my old passphrase, but then it gives me the error Bad passphrase. Which is not true, because I can add the key in pageant.exe, and I am not mistyping the passphrase...

Anything else I can try to change or drop the passphrase?


Solution 1:

puttygen on Windows doesn't seem to accept any command line arguments that I can tell. That error is complaining about not being able to find the -P key I believe. If you run puttygen.exe key.ppk instead that should load the ppk into puttygen and allow you to give it a new passphrase and then re-save your key.

Solution 2:

Check this out:

Putty does not store keys in an OpenSSH-compatible format. You need to use the "puttygen" tool to manipulate your private key.

(via this document, via Google):

To change or set a passphrase on an SSH key under PuTTY, do the following:

Run the puttygen.exe program. Click on the "Load" button. Select the private key file that you want to put a passphrase on. Enter the new desired passphrase in the "Key passphrase" and "Confirm Passphrase" fields. Click on the "Save private key" button. Overwrite the existing copy of your key.

From:

https://superuser.com/questions/522159/unable-to-change-password-for-private-ssh-key