How To Remove SSL Certificate and SSH Key Passphrase in Linux

Brief: Have you created a certificate key or private key with a passphrase and wish to remove it? In this guide, we will show how to remove a passphrase using the openssl command line tool and from an ssh private key.

A passphrase is a sequence of words used to secure and control access to a private key. It is a key or secret used to encrypt the file that contains the actual encryption key.

To use the private key for encryption, for instance for ssh public-key-based connections, you are required to decrypt the private key file using the decryption key (the passphrase) – you are prompted to enter the passphrase.

Removing a Passphrase from SSL Certificate using OpenSSL

The header of a TLS/SSL private key with a passphrase looks like what is shown in the following screenshot. The parameter “DEK-Info” stores information required to decrypt the key using the passphrase.

$ cat private.pem
View SSL Private Key Passphrase
View SSL Private Key Passphrase

When you or any application such as NGINX webserver is using the private key, which invokes it for encrypting data, you or the application will be prompted to supply the passphrase before the key can be used, for example:

$ openssl rsa -in private.pem -outform PEM -pubout -out public.pem
Enter Private Key Passphrase
Enter Private Key Passphrase

To remove the passphrase of an SSL private key using the openssl command line tool, simply copy the old file to a new file name. After, the new private key will not have a passphrase as shown in the following screenshot.

$ openssl rsa -in private.pem -out private_new.pem 
$ cat private_new.pem 
Remove SSL Private Key Passphrase
Remove SSL Private Key Passphrase

Remove Passphrase from SSH Private Key

Usually, when you generate an SSH key pair, you are prompted to set a passphrase for the private key as shown in the following screenshot. If you leave it empty, no passphrase is set.

Generate SSH Private Key Passphrase
Generate SSH Private Key Passphrase

When you invoke a private ssh key that has a passphrase, before the ssh client can use the key for the connection, it prompts you to supply the passphrase as shown.

$ ssh -i .ssh/tecmint [email protected]
Enter SSH Private Key Passphrase
Enter SSH Private Key Passphrase

To remove the passphrase, use the ssh-keygen command with the -p option which prompts you for the existing passphrase, and -f to specify the private key file:

$ ssh-keygen -p -f .ssh/tecmint

Enter the old passphrase, and leave the new passphrase empty.

Remove SSH Private Key Passphrase
Remove SSH Private Key Passphrase

[ You might also like: Basic SSH Command Usage and Configuration in Linux ]

That’s all! Remember that is recommended to use passphrases to increase the security of your SSH keys. To share your thoughts with us about this guide, use the comment form below.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Aaron Kili
Aaron Kili
Contributor
About the author

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.