Fixing 'Enter passphrase for key' Issue With SSH

Lately, whenever I tried accessing a server via SSH, it asked for a passphrase:

Enter passphrase for key '/home/abhishek/.ssh/id_rsa':

Interestingly, it was asking for my local system's account password, not the remote server's.

Entering the account password for SSH key is a pain. So, I fixed it with this command which basically resets the password:

ssh-keygen -p

It then asked for the file which has the key. This is the private ssh key, usually located in .ssh/id_rsa file. I provided the absolute path for that.

Now it asked for the 'old passphrase' which is the local user account password. I provided it one more time and then just pressed enter for the new passphrase.

❯ ssh-keygen -p
Enter file in which the key is (/home/abhishek/.ssh/id_ed25519): /home/abhishek/.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.

And thus, it didn't ask you to enter passphrase for the SSH private key anymore. Did not even need a reboot or anything.

Wondering why it happened and how it was fixed? Let's go in detail.

What caused 'Enter passphrase for key' issue?

Here is my efficient SSH workflow. I have the same set of SSH keys on my personal systems, so I don't have to create them new and add them to the servers when I install a new distro.

Since the public SSH key is added to the servers, I don't have to enter the root password for the servers every time I use SSH.

And then I have an SSH config file in place that maps the server's IP address with an easily identifiable name. It further smoothens my workflow.

Recently, I switched my personal system to CachyOS. I copied my usual SSH keys from an earlier backup and gave them the right permission.

But when I tried accessing any server, it asked for a passphrase:

Enter passphrase for key '/home/abhishek/.ssh/id_rsa':

No, it was not the remote server's user-password. It asked for my regular, local system's password as if I were using sudo.

I am guessing that some settings somewhere were left untouched and it started requiring a password to unlock the private SSH key.

This is an extra layer of security, and I don't like the inconvenience that comes with it.

One method to use SSH without entering the password each time to unlock is to reset the password on the SSH key.

And that's what you saw at the beginning of this article.

Fixing it by resetting the password on SSH key

Note down the location of your SSH private key. Usually, it is ~/.ssh/id_rsa unless you have multiple SSH key sets for different servers.

Enter the following command to reset the password on an SSH key:

ssh-keygen -p

It will ask you for the path to key. Provide the absolute path to your private SSH key.

Enter file in which the key is (/home/abhishek/.ssh/id_ed25519):

It then asks to enter old passphrase which should your local account's password. The same one that you use for sudo.

Enter old passphrase:

Once you have entered that, it will ask you to enter new passphrase. Keep it empty by pressing the enter key. This way, it won't have any password.

Enter new passphrase (empty for no passphrase):

Press enter key again when it asks:

Enter same passphrase again:

And that's about it.

You can instantly verify it. You don't need to reboot the system or even log out from the terminal.

Enjoy SSH 😄