Forgot password to id_rsa [duplicate]
I forgot the password to my ssh. I am planning to remove the files (id_rsa, id_rsa.pub and known_hosts) in the directory and starting from scratch. I haven't been using ssh since the whole heartbleed thing and I've cleared out the stuff in the keys before but I think I did it wrong.
My question is how do I recreate the files properly and set up ssh to stop asking me for passwords when I'm connecting to git or other things?
1 Answer
You need to remove your SSH public/private keys, recreate them, and then add your newly created public key to the servers and online services you use.
Remove your SSH public/private keys:
rm ~/.ssh/id_rsa*Recreate the keypair, choosing a new passphrase:
ssh-keygen -t rsa -f ~/.ssh/id_rsaAdd the newly created private key to your OS X Keychain to store the passphrase and manage unlocking it automatically:
ssh-add -k ~/.ssh/id_rsaCopy the public key to the OS X clipboard for adding to web services like GitHub, etc.
cat ~/.ssh/id_rsa.pub | pbcopyAdd your newly created public key to the
~/.ssh/authorized_keysfile of the remote server. Be sure to ensure the correct permissions of both the remote~/.sshfolder (700) and~/.ssh/authorized_keys(600). You may want to investigate usingssh-copy-idto ease this process.
Edited on 11/18/2021
4