user938363
user938363

Reputation: 10358

Why git identity is keep losing with bitbucket repo?

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 [email protected]
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?

Upvotes: 0

Views: 410

Answers (1)

Jakuje
Jakuje

Reputation: 25966

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

$ ssh -T -i /path/to/id_rsa [email protected]

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:

Host bitbucket.org
  User git
  IdentityFile /path/to/id_rsa

and then connecting using

$ ssh -T [email protected]

will work too.

Upvotes: 2

Related Questions