【问题标题】:Github Gist via SSH protocol doesn't work通过 SSH 协议的 Github Gist 不起作用
【发布时间】:2017-06-13 00:51:47
【问题描述】:

我正在使用双因素身份验证,这就是为什么 HTTPS 不是使用 GitHub 存储库和 gists 的便捷方式。

我的 ~/.ssh 目录中有正确的 configgithub_pr_key 文件。

我能够克隆我所有的个人和公共存储库。

但我无法通过 SSH 克隆我的任何私人或公共 gists,我有这个错误:

~/Desktop >> git clone git@gist.github.com: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.

如何解决?

【问题讨论】:

    标签: github ssh gist


    【解决方案1】:

    首先检查“Error: Permission denied (publickey)”中提到的原因。
    仔细检查ssh -Tv git@github.com 的输出,确认您的公钥已在您的 GitHub 帐户中注册。

    但不要忘记,您仍然可以use https with 2FA
    Create a PAT (Personnal Access Token),并将其用作密码。
    这应该足以让您克隆任何东西,包括您的私人 Gists。

    最后,尝试通过 ssh 使用 git@github.com 而不是 git@gist.github.com 进行克隆(如 in 2013 所示,即使 git@gist.github.com 应该可以工作):

    git clone git@github.com:d1b8041051e62aa34f337b3dabc77d9a.git <=== does work 
    NOT
    git clone git@gist.github.com:d1b8041051e62aa34f337b3dabc77d9a.git  
    

    只是为了测试,也可以试试:

    git clone ssh://git@gist.github.com/d1b8041051e62aa34f337b3dabc77d9a.git  
    

    (这次是git@gist.github.com

    【讨论】:

    • 我已经执行了 ssh -Tv git@github.com 并且似乎没问题:prntscr.com/fez2gn
    • @КагарлицкийДмитрий 确实...你能用 ssh 克隆一个你的私人 repo(repo,不是 gist)吗?关于要点,至少可以使用 https 克隆(使用令牌作为密码)吗?
    • 我可以通过 SSH 和 HTTPS 克隆私有仓库;我可以通过 HTTPS 克隆 Gist,但不能通过 SSH
    • 谢谢,正确的是 git clone git@github.com:d1b8041051e62aa34f337b3dabc77d9a.git
    最近更新 更多