Adding or replacing a passphrase for an existing keyTo change your passphrase, you can simply run the ssh-keygen -p command. Specify the location of your current key, and input any old or new passphrases. There is no need to regenerate keys. Enter new passphrase (empty for no passphrase):
You can login to a remote Linux server without entering password in 3 simple steps using ssky-keygen and ssh-copy-id as explained in this article. ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host's public key to the remote-host's authorized_keys file.
Try the command ssh-keygen -p -f keyfile
From the ssh-keygen man page
-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.
-f filename
Specifies the filename of the key file.
Example:
ssh-keygen -p -f ~/.ssh/id_rsa
Use the -p option to ssh-keygen. This allows you to change the password rather than generate a new key.
Change the password as sigjuice shows:
ssh-keygen -p -f ~/.ssh/id_rsa
The required password will be the new password. (This assumes you have added the public key ~/.ssh/id_rsa.pub
to your authorized_keys files.) Test with ssh:
ssh -i ~/.ssh/id_rsa localhost
You can have multiple keys with different names for different uses.
You can also use openssl
:
openssl rsa -aes256 -in ~/.ssh/your_key -out ~/.ssh/your_key.enc
mv ~/.ssh/your_key.enc ~/.ssh/your_key
chmod 600 ~/.ssh/your_key
see: https://security.stackexchange.com/a/59164/194668
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With