4

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?

Chirag
  • 567
  • 5
  • 20

1 Answers1

3

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.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • Changed the HostName settings to bitbucket.org. Also added indentation. Doesn't work – Chirag May 15 '17 at 13:30
  • How does `git remote -v` look for a repo that does not work and can you do `ssh bitbucket-office.org` successfully, being told with which account you logged in. (Should be the one associated with the respective public key) – Vampire May 15 '17 at 13:33
  • PTY allocation request failed on channel 0. Logged in as "my_username". You can use git or hg to connect to Bitbucket. Shell access is disabled. Connection to bitbucket.org closed. when I try to ssh bitbucket-office.org – Chirag May 16 '17 at 06:17
  • Ok, then your ssh config file is correct and fine now if `my_username` is correct for `office`, how about my other question? – Vampire May 16 '17 at 06:27
  • git remote -v gives me this: origin git@bitbucket.org:folder/office.git (fetch) origin git@bitbucket.org:folder/office.git (push) – Chirag May 16 '17 at 06:31
  • Well, I guess you see the problem yourself now? You don't use your ssh config. The URL of course has to be `bitbucket-office.org:folder/office.git` and not `git@bitbucket.org:folder/office.git`. Do `git remote set-url origin bitbucket-office.org:folder/office.git`. – Vampire May 16 '17 at 06:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/144309/discussion-between-chirag-shah-and-vampire). – Chirag May 16 '17 at 06:39