Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

git - Remote: Permission to repo denied at github

Now I am trying to use my personal account to push code to my personal repo. However, my current laptop also has set up my company git account.

That's why I tried to set up different account in terminal. However, after trying various video, including this one https://www.youtube.com/watch?v=fnSRBRiQIU8. I still get the error below:

remote: Permission to user2/repo.git denied to user1.

Could anyone provide any insight to make it work? At least, let me commit as User2, but not User1. Thanks a lot!

question from:https://stackoverflow.com/questions/66059053/remote-permission-to-repo-denied-at-github

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think ssh-agent can only handle one ssh key per session, so it is necessary to run ssh-add -D to drop all the keys first, and then add the key you want to use with:

ssh-add ~/.ssh/<rsa-key-file>

If your ~/.ssh/config looks like the following:

# personal
Host github.com
    HostName github.com-personal
    User git
    IdentityFile ~/.ssh/id_rsa_personal

then you can run ssh -T [email protected] to confirm that your key is successfully authenticated :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...