On $ ssh localhost
, I was being asked to provide password. It was tedious and kind of annoying to provide password for every login.
So, I have created ssh keys with passphrase..
$ ssh-keygen -t rsa
I have copied the content of the ~/.ssh/id_rsa.pub
to ~/.ssh/authorized_keys
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
Now, on $ ssh localhost
I was being asked to provide passphrase. No improvement, but instead of providing password I was providing passphrase.
I came across Adding public key to ~/.ssh/authorized_keys does not log me in automatically, but it did not address my problem. As the comment states, that if the the keys were created with a passphrase, it will always ask for passphrase.
However, if the the ssh keys would have been created without passphrase, passphrase would not be required for any ssh
operation.
The key take away from this post was the verbose flag -v
and
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
On searching about PEM_read_PrivateKey failed
I came across quite a number of posts, couple of them are from stackoverflow itself.
But could not find a proper solution.
Then I came across Setting up passwordless, passphraseless ssh which states about using a ssh agent to enter the passphrase automatically.
$ eval `ssh-agent`
$ ssh-add ~/.ssh/id_rsa
or
$ eval `ssh-agent` && ssh-add ~/.ssh/id_rsa
but again, it solved only for that specific session. Every time I start a new session I have to execute the
$ eval `ssh-agent` && ssh-add ~/.ssh/id_rsa
I could add it to my .bashrc or .zshrc but it's annoying to enter the passphrase for every session.
Is there any way to use the same ssh-agent across session?