From time to time I have to update passwords used to secure private keys to keep myself a bit more sane.
I will demonstrate simple and straightforward way to accomplish this task.
Set new passphrase interactively.
$ ssh-keygen -p
Enter file in which the key is (/home/milosz/.ssh/id_rsa): /home/milosz/.ssh/knowledge_base_key Enter old passphrase: ********** Enter new passphrase (empty for no passphrase): ********** Enter same passphrase again: ********** Your identification has been saved with the new passphrase.
Set new passphrase interactively for specified key.
$ ssh-keygen -p -f ~/.ssh/knowledge_base_key
Enter old passphrase: ********** Enter new passphrase (empty for no passphrase): ********** Enter same passphrase again: ********** Your identification has been saved with the new passphrase.
Set new passphrase interactively for a specified key with empty passphrase.
$ ssh-keygen -p -f ~/.ssh/knowledge_base_key -P ""
Enter new passphrase (empty for no passphrase): ********** Enter same passphrase again: ********** Your identification has been saved with the new passphrase.
Set new passphrase non-interactively.
$ ssh-keygen -p -f ~/.ssh/knowledge_base_key -P "oldpass" -N "newpass"
Your identification has been saved with the new passphrase.
Remember, set empty passphrase to remove it.