I am using git with multiple accounts (two) on the same local machine. I created a new ssh-key for the new user (id_rsa_new_user) and I have changed the config file accordingly to allow multiple users, by adding
#new_user's account
Host github.com-new_user
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_new_user
I logged-in with new git credential by
git config --local user.name "new_user_ID"
git config --local user.email "[email protected]"
and I checked that the login is successful by running
git config --global --list
Problem: when I run
ssh -T [email protected]
I am still logged in with the previous user, and this does not allow me to git push or pull properly. How can I authenticate myself via ssh on github with the new user?
Thank you all
When you define an entry in your ~/.ssh/config file, you need to use that entry in your SSH URL, or it won't select the right private key:
ssh -Tv github.com-new_user
No need to add git@ in front of that SSH URL: everyhing is already specified in the config file.
As noted, user.name/user.email are for commit authorship and play no role in authentication (SSH or HTTPS)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With