0

I have two Github accounts (I know this is kind of dumb, but it's company policy):

UserA is my work account, and I authenticate using my pubkey on my work machine.

UserB is my personal account, and want to push to a private repo from my work machine, using my personal username/password as credentials (as opposed to a pubkey).

However, when I try to push to a private repo on a UserB account from my work machine, I get a permissions error:

ERROR: Permission to <UserB>/<new repo>.git denied to <UserA>.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The new repo definitely exists on Github.

As other posts have suggested, I have tried git push <UserB>@github.com:<UserB>/<new repo>.git master:master, but I get a similar error: Permission denied (publickey).

How do I force git to authenticate as UserB on push without adding the SSh key from my work machine to the UserB account??

nipponese
  • 2,813
  • 6
  • 35
  • 51
  • 2
    Use HTTPS url: `git push https://github.com//.git master:master` – Leon Aug 29 '17 at 18:51
  • Possible duplicate of [How do I manage multiple ssh keys to be used on two different private repository in GIT](https://stackoverflow.com/questions/36210593/how-do-i-manage-multiple-ssh-keys-to-be-used-on-two-different-private-repository) – phd Aug 29 '17 at 20:21
  • @phd I am not asking how to manage two different keys, I am asking how to auth with username/password on different account. – nipponese Aug 29 '17 at 23:40
  • And the second SSH key is the answer. Or switch to http(s). Or temporary disable (comment it out in the config) the first SSH key. – phd Aug 30 '17 at 12:24

1 Answers1

0

Create another key on your local machine and associate it to the other account.

yorammi
  • 6,272
  • 1
  • 28
  • 34