1

I have this setup in .ssh/config. Every time I do a git push it will says permission deny.

My 1st question is that what exactly is Host and HostName?

2nd question is that if I change bitbucket_personal to bitbucket.org and bitbucket_work to bitbucket.org. bitbucket_work (the last one in config) will always work, no permission denied issue. Is it a way to make the following config work?

Host bitbucket_personal
  HostName bitbucket.org
  User kenpeter
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

Host bitbucket_work
  HostName bitbucket.org
  User kenpeter_work
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_work  

Ref: https://confluence.atlassian.com/bitbucket/configure-multiple-ssh-identities-for-gitbash-mac-osx-linux-271943168.html

Jakuje
  • 24,773
  • 12
  • 69
  • 75
kenpeter
  • 7,404
  • 14
  • 64
  • 95
  • You should be able to diagnose what's going on, roughly. What would `ssh -vT git@bitbucket-personal` tell you? If need be, replace `git` with whatever name you SSH to that server normally. – Makoto Jun 19 '17 at 01:59

2 Answers2

0

My 1st question is that what exactly is Host and HostName?

Host and HostName are SSH options.

The first one initiates conditional block (as illustrated by the indentation) and is matched against the host that is written on command-line or in the clone URL. It can be also understood as an alias.

The HostName is basically overwriting that alias with a real hostname so you are going to end up connecting to the correct server, even if you write ssh -vT git@bitbucket_personal.

2nd question

Well ... obviously. You need to adjust the clone/push/pull URLs in the git to reflect this. Basically for clonning personal repositories, you will need to replace bitbucket.org with bitbucket_personal and for work ones accordingly with bitbucket_work. For existing repositories, do the same in the .git/config, where you can find it on several lines.

Jakuje
  • 24,773
  • 12
  • 69
  • 75
0

This is how I resolved the issue for MacOS and OpenSSH, It could help you: check this link.

Gastón Antonio Montes
  • 2,559
  • 2
  • 12
  • 15