github - 使用 Google Colab 克隆私有存储库的步骤
问题描述
我想在 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).
接下来我该怎么做?
解决方案
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
。
推荐阅读
- nrwl-nx - 如何使用 NX CLI 将命令转发到运行命令?
- web2py - web2py 中的 auth_user.password 字段格式是什么
- flutter - Flutter:同一周的 showDatePicker firstdate 和 lastdate
- python - 将“对象”列转换为日期时间
- amazon-web-services - AWS CloudFormation CodeBuild:我可以使用 ECR 图像作为环境图像吗
- javascript - If hasClass condition not working after Updating Class with jQuery
- c# - 健康伤害之间的团结延迟
- c++ - 如何使用硬件加速为 2D 图形设置 C++ 项目
- excel - 根据列和行值向特定单元格添加值
- python - pip 安装失败。导致“退出状态为 1 的命令出错”