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

后端 未结 9 1212
-上瘾入骨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:32

    The GitHub ssh setup mentions testing your GitHub connection with:

    $ ssh -T git@github.com
    

    That follow the ssh uri syntax (also illustrated in "this answer").

    But you did:

    ssh github.com
    

    (without any user). In that case, ssh reverts to the SCP syntax, which relies on a ~/.ssh/config file, with a section "github.com", to list:

    • the user
    • the hostname
    • (and optionally the public key location, but by default it will try ~/.ssh/id_rsa.pub)

    To change it to a regular SSH URL, don't edit directly your .git/config file, as shown below.
    Use the command git remote set-url:

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

提交回复
热议问题