How to Change or Update an SSH RSA Private Key Passphrase Using ssh-keygen

How to Change or Update an SSH RSA Private Key Passphrase Using ssh-keygen

I like to have the same RSA private key on all of my linux and Mac OS X boxes in order to do this, I have a need to have passphrases on certain boxes and not on others – I have  changed my passphrase by typing the below in

To update your SSH private key passphrase in place without altering the keypair, run:

cli
ssh-keygen -f ~/.ssh/id_rsa -p

Source – the man-pages below:

-f filename
Specifies the filename of the key file.

-p Requests changing the passphrase of a private key file instead of creating a new private key. The pro-
gram will prompt for the file containing the private key, for the old passphrase, and twice for the new
passphrase.

>_ Engineering Discussion 2 Comments

+ Add Field Note ↓
  1. ssh-keygen -p -f ~/.ssh/id_rsa (and -o -a 100 to upgrade the KDF rounds to modern OpenSSH format) is great because it re-encrypts the private key in place without changing the public key fingerprint on any remote authorized_keys.

  2. Saved me from rotating keys across 60+ jump hosts and routers when updating our vault passphrase policy—zero changes needed on the remote servers.

Leave a Technical Comment

Share CLI tips, hardware notes, or questions below. Inline backticks (`command`) are supported.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Engineering Notes