13

I've created an RSA keypair for ssh access to a remote server. This all works. When creating the keypair, I didn't enter a password. Now I would like to encrypt the key, secure it with a password.

Is that possible, and if so how can I do that?

How can I encrypt an existing ssh key with a password?

20

Use this command: ssh-keygen -o -p -f keyfile

Changing the private key's passphrase without changing the key

  • 1
    That's right. You can also modify passphrases later using the same -p. – Rápli András Apr 2 '16 at 19:00
  • Note -o for new format only works since 6.5 released 2014-01 and is no longer needed (now default) since 7.8 released 2018-08 (in both cases distros often don't take new version immediately). – dave_thompson_085 Jan 17 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.