Reputation: 993
Does bitbucket ssh keys and git config user have any relation with each other?
When I try ssh -T [email protected]
,
It gives a different user than when I try git config -l
for the current git repo.
How does ssh authentication for git work?
Also I am not sure the ssh keys present in my .ssh
folder are of which user?
I am not able to authenticate to bitbucket for access to the current git repo.
How do I fix this?
Upvotes: 1
Views: 1422
Reputation: 5631
Git config is not relevant to SSH authentication (or HTTP/HTTPS authentication) - it's only relevant to Git's internal tracking of commits. Similarly, SSH authentication is only relevant to the systems on either end of the SSH (in this case, your system and Bitbucket), and HTTP/HTTPS authentication is only relevant to HTTP/HTTPS authentication. It doesn't really matter if the SSH user and .git/config
user don't match; Git will do its thing, and it will run the SSH commands (with SSH's own configs) when the time comes.
The ssh -T [email protected]
check you performed shows which Bitbucket user has the relevant key added. (You can see which specific key it's using with ssh -Tv [email protected]
.) If you're unable to work on a particular Bitbucket repo using SSH, but you get a username back from ssh -T [email protected]
, then one or more things may be going on here:
The specific message you get back should indicate which of those potential problems may be the one. (You didn't really get into enough detail for us to tell.)
With Bitbucket specifically, you can also put the Bitbucket username as part of the SSH URL in the remote - something like git clone [email protected]:owner/repo
, or git remote set-url origin [email protected]:owner/repo
. This is mostly so that people who work on multiple Bitbucket accounts from the same system can keep their SSH keys distinct. ([email protected]
still works, of course, as does the ~/.ssh/config
hack, but I think the username-specific approach is a little cleaner.)
Upvotes: 2