Issue
Using a simple git command like this
$ git push --set-upstream origin master
I am getting:
ERROR: Permission to oresoftware/tsc-multi-watch.git denied to alex-teros.
I tried switching the user:
git config credential.username 'oresoftware'
but got the same error. I have this in ~/.ssh/config
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
ControlPersist 2h
Host *
ForwardAgent yes
AddKeysToAgent yes
UseKeychain yes
GSSAPIAuthentication no
ServerAliveInterval 240
ServerAliveCountMax 3
Host the1mills.github.com
HostName github.com
User the1mills
IdentityFile ~/.ssh/the1mills
Host oresoftware.github.com
HostName github.com
User oresoftware
IdentityFile ~/.ssh/oresoftware
Host bitbucket.org
HostName bitbucket.org
User oresoftware
IdentityFile ~/.ssh/oresoftware
Host alex-teros.github.com
HostName github.com
User alex-teros
IdentityFile ~/.ssh/github
Is there anything I can do to fix this? The obvious problem is that it's saying I am 'alex-teros' but I want to be 'oresoftware' for this command.
Solution
If you want your ssh config to be used, your URL should use one of its entry (referening github.com)
For instance:
oresoftware.github.com:oresoftware/tsc-multi-watch.git
Then, and only then, the right private SSH key ( ~/.ssh/oresoftware
) would be used.
You only need to replace User oresoftware
by User git
: when pushing to GitHub n SSH, the user is always git
.
Answered By - VonC