Github - I switched accounts and now I can’t click because I have the wrong username

So, I am now "jononomo" on github. A year ago, however, I was "zonomono." For some time I quit the software and bought a new laptop. Then I came back and created a new Github account under the "jononomo" handle, and now I'm trying to synchronize my dotfiles between my two laptops. From my new laptop, I created a git repository and moved it to github, where it can be viewed under the "jononomo" account. Then I went to my old laptop and cloned this repository. Everything worked as expected.

Then I made some changes to my dotfiles on my old laptop, and now I would like to forward these changes to github so that I can then transfer them to a new laptop. The problem is that when I run the command:

git push origin master 

I get an error message:

 ERROR: Permission to jononomo/.dotfiles.git denied to zononomo. 

The first thing I did was knock down my old SSH keys in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub . Then I generated new SSH keys and added my new public key to my jononomo github account. But this did not solve the problem. If I run the command:

 ssh -T git@github.com 

I get the answer:

 Hi zononomo! You've successfully authenticated, but GitHub does not provide shell access. 

Next, I watched the solution given here: https://stackoverflow.com/a/4646266/ ... This person suggested creating a ~/.ssh/config file with the following contents:

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

and then he suggested running the command:

 git remote set-url origin git@github-jononomo :jononomo/.dotfiles.git 

I tried this, but this does not fix my problem. I still get the message:

 ERROR: Permission to jononomo/.dotfiles.git denied to zononomo. 

By the way, my .gitconfig has the following contents:

 [user] name = Jon Crowell email = me@myemail.com [github] user = jononomo token = 2a18a7235746324aefec34b234aa343a email = me@myemail.com [credential] helper = osxkeychain 
+4
source share
2 answers

zononomo? GitHub should not recognize you as zononomo. Maybe you have an ssh agent providing your old key?

As stated in β€œ Troubleshooting Github Accounts on the Terminal, ” add the line:

  IdentitiesOnly yes 

into your configuration file and check if GitHub continues to use this old identifier.

however i still get

  ssh: Could not resolve hostname github: nodename nor servname provided, or not known error 

The " hostname " for permission must match the Host entry of the configuration file.

If this Host entry is github-jononomo, you should use it also in your ssh address:

 git remote set-url origin github-jononomo:jononomo/.dotfiles.git 
+2
source

I got it to work by following these steps:

At first, my ~/.ssh/config file looks like this:

 Host github-jononomo HostName github.com User git IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes 

Secondly, I ran the git remote set-url origin git@github-jononomo :jononomo/.dotfiles.git

Thirdly, I ran the command ssh -T git@github.com and got the result Hi jononomo! You've successfully authenticated, but GitHub does not provide shell access. Hi jononomo! You've successfully authenticated, but GitHub does not provide shell access.

Fourth, I logged into my old github account, deleted the SSH key, and completely deleted the account.

Thanks a lot VonC.

+3
source

Source: https://habr.com/ru/post/1442372/


All Articles