I know that are a lot of questions like this one, but no answer was able to solve this problem for redhat. I had a MACOS with two accounts with no big deal, but on Red Hat it just doesn't work.
I have 2 accounts
https://github.com/USER1/REPOSITORY_A.git
https://github.com/USER2/REPOSITORY_B.git
The earlier setup I had been to create an SSH key used for USER1 one on:
~/.ssh/id_rsa.pub
and the second USER2 on:
~/.ssh/USER2/id_rsa.pub
Added the ssh keys like:
ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/USER2/id_rsa
I had to add each key its own account SSH keys on github. And than I had to set up my config like this:
vi ~/.ssh/config
Host github.com
Hostname ssh.github.com
Port 443
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
User git
Host user2-github.com
HostName github.com
AddKeysToAgent yes
PreferredAuthentications publickey
IdentityFile ~/.ssh/user2/id_rsa
User git
Host *
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
and than I had to set up the USER2 local repository a remote host like:
git remote set-url origin git@user2-github.com:user2/REPOSITORY_B.git
On MACOS everything worked like a charm, but on redhat, when I try to push on the local (USER2) repository, it tries to use "USER1" credentials... I can't find a solution, so I think I need your help...
How to use two different github accounts with SSH and Red Hat 7?