If you forget the passphrase for your SSH key, you cannot recover it. However, you can generate a new SSH key pair. Here’s how to do that:
-
Open your terminal.
-
Remove the old key pair (if you no longer need it):
rm ~/.ssh/id_rsa ~/.ssh/id_rsa.pub -
Generate a new SSH key pair:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -
When prompted for a passphrase:
- You can choose to enter a new passphrase or leave it empty for no passphrase.
-
Copy the new public key to the target system (if needed):
cat ~/.ssh/id_rsa.pubThen, add it to the
authorized_keysfile on the target system.
Remember to update any services or systems that were using the old public key with the new one.
