ssh

How to Change SSH Private Key Passphrase?

Whenever you generate an SSH key, you will always set up a passphrase to secure it. However, you can always leave it empty; however, it is highly recommended that you set up one, which should be very strong. Also, it would help if you kept changing that passphrase from time to time to avoid its misuse or breach. We will teach you the different methods of changing the SSH private key passphrase on a Linux Mint 20 system in today’s article. However, you can also implement these methods on a Ubuntu 20.04 or a Debian 10 machine.

Methods of Changing the SSH Private Key Passphrase in Linux Mint 20

For changing the SSH private key passphrase in Linux Mint 20, you can choose any of the following two methods according to your preference. However, before proceeding with these methods, we would like to share how you can generate a new SSH key. All you have to do is to execute the following command in your Linux Mint 20 terminal:

$ ssh-keygen

Once a new SSH key has been generated, you will be able to see something like shown in the image below on your Linux Mint 20 terminal:

After generating an SSH key, you can easily proceed with either of the following two methods.

Method 1: Changing the Passphrase for the Current User’s SSH Private Key
For changing the passphrase for the current user’s SSH private key, you will have to execute the command shown below in your Linux Mint 20 terminal:

$ ssh-keygen –p

Once you run this command, you will be prompted to enter the new passphrase for the current user’s SSH private key. When you will do so, you will be asked to re-enter the very same passphrase for confirmation. After fulfilling these formalities, a new passphrase will be successfully set up for the current user’s SSH private key, as shown in the following image:

Method 2: Changing the Passphrase for a Specified SSH Private Key
For changing the passphrase for a specified SSH private key, you will have to execute the command shown below in your Linux Mint 20 terminal:

$ ssh-keygen –p –f ~/.ssh/id_rsa

Here, you can replace “.ssh/id_rsa” with the exact path to your specific SSH private key.

Once you run this command, you will be prompted to enter the old passphrase. After that, you will be asked to enter the new passphrase for the specified SSH private key. When you will do so, you will be asked to re-enter the very same passphrase for confirmation. After fulfilling these formalities, a new passphrase will be successfully set up for the specified SSH private key as shown in the following image:

Conclusion

This guide explained the two methods of changing the SSH private key passphrase on a Linux Mint 20 system. The first method was quite generic; however, you can use the second method to change the passphrase for a specific SSH private key.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.