Search code examples
gitsshbitbucketssh-keysssh-config

SSH config to access multiple repo not working


Here's the config file:

Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa

Host bitbucket-office.org
HostName bitbucket-off.org
User git
IdentityFile ~/.ssh/work_rsa

Host bitbucket-personal.org
HostName bitbucket-per.org
User git
IdentityFile ~/.ssh/personal_rsa

I don't know what's wrong with set up. I want to connect to 2 remote repos from the same local machine. Setting up a config file was the solution I found over the internet. But somehow, I am just able to use one at a time (the one created latest). When I try to pull from other repo it throws the following error:

Agent admitted failure to sign using the key.
repository access denied.
fatal: The remote end hung up unexpectedly

Both my public SSH keys are well posted in respective bitbucket accounts.

How do I make config file run as needed?


Solution

  • Your HostName settings are wrong. They should all be bitbucket.org, as you tell with this setting where to actually connect to.

    Also there should be indentation for the settings for a Host, but this might just be a posting error here. If it looks like posted though, this should also be chnanged. As far as I remember, the indentation is important and meaningful.