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

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)