gpt4 book ai didi

linux - 由于公钥问题需要帮助克隆 GitHub 存储库

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:55:31 25 4
gpt4 key购买 nike

我正在尝试在我试图启动并在虚拟机上运行的服务器中克隆私有(private) GitHub 存储库。

无论我做什么,我都会收到以下错误:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我试过很多东西。对于初学者,我确保我按照 GitHub's tutorial 正确地制作了我的 rsa key 。 .我还确定我在 ~/.ssh/id_rsa.pub 找到的公共(public) rsa key 已正确复制到我的 GitHub 帐户的 ssh key 。

我在 ~/.ssh/config 的配置文件如下所示:

Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

我试过克隆一个公共(public)仓库和一个私有(private)仓库,但都不起作用。

当我去克隆存储库时,我正在执行以下命令:

sudo git clone git@github.mit.edu:<GitHub Name>/<Repo Name>.git

如果我在没有 sudo 的情况下执行命令,我会收到以下错误:

fatal: could not create work tree dir '<Repo Name>'.: Permission denied

当我执行所有这些操作时,我处于 ​​Python 虚拟环境中。这有什么区别吗?

我一直在阅读与此事相关的 Stack Overflow 帖子,但没有一篇能帮助我解决我的问题。

任何帮助将不胜感激!谢谢!

最佳答案

您正在使用 sudo,因此 Git 使用用户 root 的 ssh key 。

要完成这项工作,您必须在不使用 sudo 的情况下调用 git。

So when I don't use sudo I get the error fatal: could not create work tree dir 'cardlearning'.: Permission denied

确保当前用户在您正在执行克隆的目录中具有写入权限。

您不能克隆到现有目录,因此作为解决方法,您可以:

$ sudo mkdir tmp
$ sudo chown $USER: tmp
$ git clone git@github.mit.edu:<GitHub Name>/<Repo Name>.git tmp/cardlearning
$ mv tmp/cardlearning ./cardlearning
$ rmdir tmp

关于linux - 由于公钥问题需要帮助克隆 GitHub 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47124148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com