Whenever I need to git pull
or git push
repo on bitbucket.org on Win10 dev laptop, almost every time I need to add the identity before I can do that. Here is the ssh -T
:
$ ssh -T git@bitbucket.org
Permission denied (publickey).
Then after eval "$(ssh-agent)
and ssh-add ~/.ssh/id_rsa
, I can git pull
or git push
. Next time I need to repeat the process again. Why the identity is keep losing? How can I add the identity once for all?
A good start is to understand the steps you are doing and how
ssh-agent
works or how you can do that better.SSH-Agent is a program storing your private key in the memory and to save you from typing passphrase for every connection. Your shell remembers the connection to this program using environment variables. So if you open new shell run
ssh-agent
and close the shell, you lose this connection (Windows does not have this anyhow integrated). Also restarting computer (obviously) stops the running agent.But you might use
which will do the same (you will have to insert passphrase if you have one). Or more cleanly using
ssh_config
in~/.ssh/config
, which can contain:and then connecting using
will work too.