Why doesn't my SSH key work for connecting to github?

后端 未结 9 1218
-上瘾入骨i
-上瘾入骨i 2021-01-30 02:19

Note: I\'m not a newb, and I\'ve done this a gazillion times, but for some reason today it decided not to work.

I keep getting the Permission denied (publickey).

9条回答
  •  情歌与酒
    2021-01-30 02:38

    If it works for other repositories, but not one in particular, then you are probably using the wrong remote url(i.e. https instead of git@github.com)

    1. First, double check that your git ssh connection is working:

      ssh -T git@github.com
      
    2. If it works, check your remote:

      git remote -v
      

      it will display something like this:

      origin  https://github.com/username/repo(fetch)
      origin  https://github.com/username/repo(push)
      
    3. If the remotes indicate https at the beginning, then you need to change this url with:

      git remote set-url origin git@github.com:usertname/repo.git
      

    Go here for more details.

提交回复
热议问题