I created and configured three ssh keys both locally and remotely as follows:
SSH keys - Emails
$> cat ~/.ssh/id_rsa.pub (E-mail Bitbucket)
ssh-rsa AAAAB3.../kJVKej/5 ricardoramos.usp@gmail.com
$> cat ~/.ssh/id_rsa_git_hub.pub (E-mail Github1 is the same account Bitbucket)
ssh-rsa AAAAB3...Iq9FkLN6L ricardoramos.usp@gmail.com
$> cat ~/.ssh/id_rsa_back_track.pub (E-mail Github2)
ssh-rsa AAAAB3N...MSdYFaZ0d ricardo.comp.ufla@gmail.com
List SSH keys (Two different ssh keys with the same email)
$> ssh-add -l
2048 6b:0b:dd...e6:b7 ricardoramos.usp@gmail.com (RSA)
2048 fc:20:37...1a:ec ricardo.comp.ufla@gmail.com (RSA)
2048 45:4c:92...40:70 ricardoramos.usp@gmail.com (RSA)
Config ~/.ssh/config file
#Default Bitbucket - User = ricardoramos
Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa
#Account GitHub1 - User = ricardousp
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_git_hub
#Account GitHub2 - User = ricardormoliveira
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_back_track
In addition, I also created a local repository with the name test and remote configuration:
$> git remote -v
origin git@github.com:ricardormoliveira/testing.git (fetch)
origin git@github.com:ricardormoliveira/testing.git (push)
But, when I try to push with my ricardormoliveira remote user the following message appears:
$> git push origin master
ERROR: Permission to ricardormoliveira/testing.git denied to ricardousp.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How do I do that git push with my ricardormoliveira user and not for ricardousp user? Why git is changing my users? What am I doing wrong?