Permission denied when pushing file to remote

心已入冬 提交于 2019-12-04 16:46:47

A couple of points here:

  • the user and email used to make commits have nothing to do with the remote repo (here hosted on GitHub) for authentication
  • SSH keys (old or new) are not used at all when pushing to GitHub with an https URL.
    If it uses your first biid-sua account, this is because of a git credential helper, that has cached your biid-sua credentials for github.com.

You can either make sure and delete that entry (either on Mac or on Windows). You will be prompt for your new username/password at the next push.

Or you can swtich to an SSH URL:

cd /path/to/my/local/repo
git remote set-url origin g2:SyedMiraj/SpringSecurityWithTicketBooking.git

And then make sure your ~/.ssh/config defines the g2 entry and references the right key (as I explain here)

#Account one
Host g1
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile /c/Users/yourname/.ssh/id_rsa_biid-sua
    User git

#Account two
Host g2
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile /c/Users/yourname/.ssh/id_rsa_smiraj
    User git

Assuming that you have name your SSH keys in HOME:

  • .ssh/id_rsa_biid-sua and .ssh/id_rsa_biid-sua.pub
  • .ssh/id_rsa_smiraj and .ssh/id_rsa_smiraj.pub

you need to change your repo config on your PC to ssh way: refer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!