OpenSSH Change a Passphrase With ssh-keygen command

by on February 4, 2008 · 8 comments· LAST UPDATED October 7, 2013

in , ,

How do I change OpenSSH passphrase for one of my private keys under Linux, OpenBSD, FreeBSD, Apple OS X or Unix like operating systems?

You need to use the ssh-keygen command to generates, change manages and converts authentication keys for ssh. You should the see following files at $HOME/.ssh or ~/.ssh directory i.e. /home/you/.ssh/. You can use the ls -l $HOME/.ssh/ command to see the following files:

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Estimated completion time1m
=> id_dsa : DSA authentication identity of the user

=> : DSA public key for authentication

=> id_rsa : RSA authentication identity of the user

=> : RSA public key for authentication

Changing a Passphrase with ssh-keygen

The -p option requests changing the passphrase of a private key file instead of creating a new private key. The program will prompt for the file containing the private key, for the old passphrase, and twice for the new passphrase. Use -f {filename} option to specifies the filename of the key file. For example, change directory to $HOME/.ssh. Open the Terminal app and then type:
$ cd ~/.ssh/

To change DSA passphrase, enter:
$ ssh-keygen -f id_dsa -p

To change RSA passphrase, enter:
$ ssh-keygen -f id_rsa -p
Sample outputs:

Animated gif 01: Changing your openssh passphrase

Animated gif 01: Changing your openssh passphrase

  • See ssh-keygen(1) man page for information on command line options.
Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 8 comments… read them below or add one }

1 Stu February 4, 2008 at 8:07 pm

If something relies on the private key will it still work the same way? I mean a SSL certificate for example…


2 JOsh Beauregard October 16, 2009 at 2:54 pm

thanx for the quick mem check


3 Pierre Dej July 19, 2010 at 9:20 am

Thanks for this!


4 bambini vestiti April 2, 2011 at 10:42 am

Thank applause and encouragement, for the valid reason that he offers me better power and courage!


5 rebecca September 21, 2012 at 12:48 am

change password key to best family ever


6 Richard November 7, 2013 at 5:35 pm

for newbie like me, I had to also add ‘ssh-add id-rsa’ to make it work. Very helpful tutorial


7 Sumanth November 8, 2013 at 10:58 am

Thank you very much, its indeed a very helpful article


8 Murphy Randle April 23, 2014 at 2:51 am

This is just what I needed. Thanks! And the animated gif demonstration was extra helpful. :)


Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: