How to change passphrase for RSA key file
Just like any password, changing passphrase of your ssh key is a better way to ensure that your RSA key is secure.
ssh-keygen command can be used to change the passphrase using the -p switch.
Command is as follows.
ssh-keygen -p
Following is an example used for changing ssh RSA key passphrase.
[k@sysadminforest ~]$ ssh-keygen -p
Enter file in which the key is (/home/k/.ssh/id_rsa):
Enter old passphrase:
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
Once you type the command and hit ENTER, it prompts for location of the key file.
You can choose the default option if it is the one you want to change to.
Else, you can provide a different file path.
Next, you need to provide old passphrase. Hit enter if you have no passphrase now.
Next, enter the new passphrase you wish to set and hit ENTER. It will ask to enter the same passphrase again. Do it and hit ENTER. Now , you are done!
If you want to change passphrase and specify the location of the key file in a single command, you can use the -f option with -p switch.
[k@sysadminforest ~]$ ssh-keygen -p
[k@sysadminforest ~]$ ssh-keygen -t rsa -p -f /home/k/newkeys/id_rsa
Enter old passphrase:
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
[k@sysadminforest ~]$
You can generate an RSA key from command line using this link.