【问题标题】:steps to clone a private repository using Google Colab使用 Google Colab 克隆私有存储库的步骤
【发布时间】:2020-08-10 12:28:44
【问题描述】:

我想在 Google Colab 中克隆一个私有仓库,

我在 colab 上打开了一个笔记本并做了以下操作:

%cd "content/drive/My Drive/project"
!rm -rf /root/.ssh*
!mkdir /root/.ssh
!ssh-keygen -t rsa -b 4096 -C "githubname@github.com"

然后我通过

打开了公钥
 !cat /root/.ssh/id_rsa.put

我复制了运行命令后显示的公钥,并使用此密钥在我的 GitHub 中创建了一个新密钥。

然后我尝试了以下方法:

!ssh-keyscan GitHub.com >> /root/.ssh/known_hosts
!chmod 644 /root/.ssh/known_hosts
!chmod 600 /root/ssh/id_rsa
!ssh -T github.com

然后我得到以下信息(权限被拒绝)

# github.com:22 SSH-2.0-babeld-d45c1532
# github.com:22 SSH-2.0-babeld-d45c1532
# github.com:22 SSH-2.0-babeld-d45c1532
Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
root@github.com: Permission denied (publickey).

接下来我该怎么做?

【问题讨论】:

  • 我认为目前还没有一种特别安全的增强方式来做到这一点。使用当前可用的方法,您要么将密码/令牌提供给 Google Colab,要么将私钥存储在您的 Google Colab 会话中,这两种方式都远非理想。直到 colab 与 Github 进行一些身份集成或可能永远不会发生的事情。

标签: github google-colaboratory


【解决方案1】:
ssh -T github.com
root@github.com: Permission denied (publickey)

这是意料之中的:

  • 正确的测试是:

    ssh -T git@github.com
    
  • 与 GitHub 一起使用的正确 SSH URL 是:

    git@github.com:<me>/<myRepo>
    

您始终使用“git”,而不是“root”(或您当前的本地用户)作为远程用户连接到 GitHub。

您的本地帐户仍然是“root”(它包含公共和私人 SSH 密钥)

但连接到 GitHub 意味着使用远程帐户git

【讨论】:

  • 这是给我的。添加更多搜索短语以使其更易于查找:ssh -T git@github.com test succeeds “您已成功通过身份验证,但 GitHub 不提供 shell 访问。”但错误的git clone URL 导致“root@github.com: Permission denied (publickey)./fatal: could not read from remote repository.”
猜你喜欢
  • 2020-10-08
  • 2021-02-04
  • 2015-07-24
  • 2014-10-30
  • 2022-07-13
  • 1970-01-01
  • 2022-01-23
  • 2021-09-04
  • 2019-05-13
相关资源
最近更新 更多