I have an existing public/private key pair, the private key is password protected, the encryption may be either RSA or DSA. These keys are the kind you generate with ssh-keygen and generally store under ~/.ssh.

I'd like to change the private key's password. How do I go about it, on a standard unix shell?

Also, how do I simply remove the password? Just change it to empty?

(I know, they call it a passphrase. Pedantic wimps.)

link|improve this question

40% accept rate
feedback

1 Answer

up vote 20 down vote accepted

To change the passphrase on your default DSA key:

$ ssh-keygen -p -f ~/.ssh/id_dsa

then provide your old and new passphrase (twice) at the prompts.

More details from man ssh-keygen:

[...]
SYNOPSIS
    ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment]
               [-f output_keyfile]
    ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
[...]
     -f filename
             Specifies the filename of the key file.
[...]
     -N new_passphrase
             Provides the new passphrase.

     -P passphrase
             Provides the (old) passphrase.

     -p      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.
[...]
link|improve this answer
This is from the man page shipping with net-misc/openssh-5.2_p1-r2 on Gentoo Linux. – Mike Mazur Aug 6 '09 at 6:04
5  
sneaky way to say RTFM :P – kch Aug 6 '09 at 6:07
Or, more precisely, for a default location DSA key, ssh-keygen -pf ~/.ssh/id_dsa – kch Aug 6 '09 at 6:11
I like providing the key file as arg, can you update your answer to reflect my whimsical penchants so I can accept it without reservations? #pedanticwho – kch Aug 6 '09 at 6:14
Also, for the sake of future lazy person, I'd reverse the order: quick answser first, man page later. – kch Aug 6 '09 at 6:15
feedback

Your Answer

 
or
required, but never shown

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