问题
First of all I know that this question has been asked and answered several times, but all solutions that I've found don't work.
Task is very simple - I have two GitHub accounts, one personal and second for business.
I tried to use a few configurations, but all were like this:
Host github.com-personal
HostName github.com
User kagarlickij
IdentityFile ~/.ssh/github_kagarlickij_private
Host github.com-business
HostName github.com
User dmytriy-kagarlickij
IdentityFile ~/.ssh/github_dmytriy-kagarlickij-business_private
... and it doesn't work. It works only if Host is github.com . Not github.com-business , not business.github.com , etc
Any ideas how to manage this?
回答1:
The User
for ssh (push/pull) access is always "git", not your username.
Edit: Also, you must use the ssh alias from your config in the clone url:
git clone github.com-personal:kagarlickij/terraform-aws-vm.git
If you do that ssh uses the hostname, user and identify from the corresponding config file section.
来源:https://stackoverflow.com/questions/46666016/two-github-accounts-on-the-same-computer