Removing a passphrase from a SSH key

Here I explain how you can remove a passphrase from a SSH key.

Why would you want to do this?

There may be cases where you have deployed a SSH key with a passphrase but now want to use it in a script. While you can add the key to the currently running SSH agent it may be easier to have a copy of the key without the passphrase.

Since the passphrase just allows the use of the key, removing it won’t affect the public key of the associated private key. This means we can easily remove the passphrase and still have it usable in the same way as before with the phrase.

Removing the passphrase from a SSH key

Before starting this it is recommended to backup your SSH key.

To start the process of removing a passphrase from a SSH key type:

ssh-keygen -p

Once this has started you will be asked where the SSH key exists. Once you have given this information it will ask for the current passphrase and a new passphrase to set.

We can remove the passphrase from the SSH key by not setting the passphrase when asked. By doing this we will have removed the passphrase from the key.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.