6

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?

1 Answer 1

8

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, try ssh -Tv [email protected] and compare.

In my case, the latter was using the wrong public key because .ssh/config specified IdentityFile under Host github.com.
I changed that to Host github.com *.github.com and problems solved.

Sign up to request clarification or add additional context in comments.

6 Comments

I've executed ssh -Tv [email protected] and it seems to be fine: prntscr.com/fez2gn
@КагарлицкийДмитрий It does indeed... Can you clone one your your private repo (repo, not gist) with ssh? Regarding gist, would at least an https clone work (with a token as password)?
I can clone private repos via SSH and HTTPS;and I can clone Gists via HTTPS, but not via SSH
thanks, the correct one is git clone [email protected]:d1b8041051e62aa34f337b3dabc77d9a.git
@Jacktose Thank you for the feedback. Good point. I have included your comment in the answer for more visibility.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.