I read and followed some online documentation on how to set up a ssh-agent so that I don't need to type in password every time I ssh to a remote machine.
However, with the help of ssh-agent, I still need to do ssh-add
every time I restart the shell. The ssh-add
then asks me to enter the passphrase to unlock the private key.
Enter passphrase for key '/home/xx/.ssh/id_rsa':
Instead of typing in my password for the remote machine, I am asked to type in the password for the private key. It's like stepping out of a purgatory and found myself in a hell afterwards. It looks like the id_rsa is only temporarily added to the ssh-agent in a session, because every time I log in and type ssh-add -l
. I get:
The agent has no identities.
May I ask how permanently store the key (id_rsa) in ssh-agent? Thanks
EDIT: this is what I did with ssh-agent
. I appended the following block into ~/.bash_profile
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi
Best Answer
I have installed keychain.
sudo apt-get install keychain
If you're running bash you need to add a few commands to your .bash_profile If you do not have a .bash_profile create one in your home folder. Add these lines:
At the start of a work day I will login. When I open a terminal, I will be prompted once for my passphrase. For all other new terminals and connections I will not be asked for my passphrase again.