Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github wrong username

Tags:

github

account

I have setup with guthub with a previous github account on this computer called myaccount when i run this command

ssh -T [email protected]
Hi myaccount! You've successfully authenticated, but GitHub does not provide shell access.

Ok but i have now setup a new github account called samaccount but i cant run this command i get this error.

git push -u origin master

i get this error

ERROR: Permission to samueleast/Samuel-East-S3-Audio-Playlist-Player.git denied to myaccount.

I dont want it to use myaccount it should be using samaccount !!!

i have followed all the steps here http://help.github.com/mac-set-up-git/ setup brand new ssh key.

and also run this command many times

git config --global user.name "samaccount"

but it still uses myaccount its sooo annoying where am i going wrong???

like image 503
DCHP Avatar asked Nov 16 '11 12:11

DCHP


1 Answers

GitHub recognizes you as myaccount because SSH is using a key that corresponds to a public key that has been added to the myaccount account on the GitHub website.

If you want to switch entirely to using the sameueleast account instead of myaccount, you can do the following:

  • Login to GitHub's website as myaccount
  • Go to "Account Settings"
  • Go to "SSH Public Keys"
  • Delete your public key from that list
  • Logout
  • Login to GitHub's website as samueleast
  • Go to "Account Settings" -> "SSH Public Keys"
  • Select "Add another public key" and paste in the contents of your public key. You public key will (probably) be called id_rsa.pub or id_dsa.pub and be in your .ssh directory.

On the other hand, if you want to be able to use either myaccount or samueleast when pushing to GitHub, you will need to create aliases for [email protected] in ~/.ssh/config, such as:

Host github-myaccount
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_dsa-myaccount.pub

Host github-samueleast
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_dsa-samueleast.pub

That assumes you've generated a second SSH keypair and given them names as above. Then you need to make sure that you are using the appropriate alias in the URLs of your git remotes. For example, if you want to change your origin remote so that pushing to origin means "pushing to origin as samueleast", you could do:

 git remote set-url origin \
     git@github-samueleast:samueleast/Samuel-East-S3-Audio-Playlist-Player.git
like image 87
Mark Longair Avatar answered Oct 05 '22 20:10

Mark Longair