Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.)

share|improve this question

1 Answer 1

up vote 48 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.
[...]
share|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
9  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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