Reputation: 8107
I'm using two-factor auth and that's why HTTPS isn't convenient way to work with GitHub repos and gists.
I have correct config and github_pr_key files in my ~/.ssh directory.
I'm able to clone all my personal and public repos.
But I can't clone via SSH any of my private or public gists, I have this error:
~/Desktop >> git clone [email protected]:d1b8041051e62aa34f337b3dabc77d9a.git
Cloning into 'd1b8041051e62aa34f337b3dabc77d9a'...
The authenticity of host 'gist.github.com (192.30.253.118)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl22E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gist.github.com,192.30.253.118' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How it can be fixed?
Upvotes: 6
Views: 954
Reputation: 1323743
Check first the reasons mentioned in "Error: Permission denied (publickey)".
Double-check the output of ssh -Tv [email protected]
, to confirm your public key is registered on your GitHub account.
But don't forget that you can still use https with 2FA.
Create a PAT (Personnal Access Token), and use it as password.
That should be enough to allow you to clone anything, including your private Gists.
Finally, try to clone through ssh with [email protected]
, not [email protected]
(as seen in 2013, even though [email protected]
should work):
git clone [email protected]:d1b8041051e62aa34f337b3dabc77d9a.git <=== does work
NOT
git clone [email protected]:d1b8041051e62aa34f337b3dabc77d9a.git
Just for testing, try also:
git clone ssh://[email protected]/d1b8041051e62aa34f337b3dabc77d9a.git
(this time with [email protected]
)
As noted by Jacktose in the comments:
If
ssh -Tv [email protected]
works, tryssh -Tv [email protected]
and compare.In my case, the latter was using the wrong public key because
.ssh/config
specifiedIdentityFile
underHost github.com
.
I changed that toHost github.com *.github.com
and problems solved.
Upvotes: 8