Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 由于公钥问题,需要帮助克隆GitHub存储库_Linux_Git_Github_Ssh - Fatal编程技术网

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

Linux 由于公钥问题,需要帮助克隆GitHub存储库,linux,git,github,ssh,Linux,Git,Github,Ssh,我正在尝试在一台服务器上克隆一个私有GitHub存储库,该服务器是我试图建立并在虚拟机上运行的 无论我做什么,我总是得到以下错误: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. fatal: could not create wo

我正在尝试在一台服务器上克隆一个私有GitHub存储库,该服务器是我试图建立并在虚拟机上运行的

无论我做什么,我总是得到以下错误:

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

Please make sure you have the correct access rights
and the repository exists.
fatal: could not create work tree dir '<Repo Name>'.: Permission denied
我试过很多东西。首先,我通过以下方法确保我的rsa密钥是正确的。我还确信在
~/.ssh/id\u rsa.pub
上找到的我的公共rsa密钥已正确复制到我的GitHub帐户的ssh密钥中

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

Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
我尝试过克隆一个公共存储库和一个私有存储库,但两者都不起作用

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

sudo git clone git@github.mit.edu:<GitHub Name>/<Repo Name>.git
当我执行所有这些操作时,我处于Python虚拟环境中。这有什么区别吗

我一直在阅读与此相关的堆栈溢出帖子,但没有一篇能够帮助我解决我的问题


任何帮助都将不胜感激!谢谢大家!

检查您的用户是否有权限写入您所在的目录

或执行

git clone git@github.mit.edu:<GitHub Name>/<Repo Name>.git ~/myRepo
git克隆git@github.mit.edu:/.git~/myRepo
将其放置在主目录的
myRepo
子目录中


使用
~
引用路径时,不要使用sudo编辑ssh配置,因为您可能最终编辑
根用户的
ssh
首选项,而不是您的用户。同样,不要使用
sudo
克隆存储库,因为它将尝试使用
root
用户的
ssh
键进行连接。

检查您的用户是否有权限写入您所在的目录

或执行

git clone git@github.mit.edu:<GitHub Name>/<Repo Name>.git ~/myRepo
git克隆git@github.mit.edu:/.git~/myRepo
将其放置在主目录的
myRepo
子目录中


使用
~
引用路径时,不要使用sudo编辑ssh配置,因为您可能最终编辑
根用户的
ssh
首选项,而不是您的用户。同样,不要使用
sudo
克隆存储库,因为它将尝试使用
root
用户的
ssh
键进行连接。

您使用的是
sudo
,所以Git使用的是user
root
的ssh键

要实现这一点,您必须在没有
sudo
的情况下调用git

因此,当我不使用sudo时,会出现致命错误:无法创建工作 树目录“cardlearning.”:权限被拒绝

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

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

$ 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
$sudo mkdir tmp
$sudo chown$用户:tmp
$git克隆git@github.mit.edu:/.git tmp/cardlearning
$mv tmp/cardlearning./cardlearning
$rmdir tmp

您使用的是
sudo
,因此Git使用的是user
root
的ssh密钥

要实现这一点,您必须在没有
sudo
的情况下调用git

因此,当我不使用sudo时,会出现致命错误:无法创建工作 树目录“cardlearning.”:权限被拒绝

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

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

$ 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
$sudo mkdir tmp
$sudo chown$用户:tmp
$git克隆git@github.mit.edu:/.git tmp/cardlearning
$mv tmp/cardlearning./cardlearning
$rmdir tmp

不要使用
sudo
所以当我不使用
sudo
时,我会出现错误
致命:无法创建工作树目录“”:权限被拒绝
不要使用
sudo
所以当我不使用
sudo
时,我会出现错误
致命:无法创建工作树目录“”:权限被拒绝,我似乎更进一步了,但是我在
~/.ssh/config
中的
config
文件中发现了一些错误,即:
/home/agaidis/.ssh/config:line 2:Bad配置选项:addkeystagent/home/agaidis/.ssh/config:line 3:Bad配置选项:usekeychain/home/agaidis/.ssh/config:terminating,2个错误的配置选项致命:无法从远程存储库读取。请确保您具有正确的访问权限,并且存储库存在。
~/.ssh/config
文件中删除无效选项。删除粘贴在您的问题中的所有四条指令应该没问题。谢谢!这真的救了我一命。当我这么做的时候,我似乎更进一步了,但是我在
~/.ssh/config
中的
config
文件中发现了一些错误,即:
/home/agaidis/.ssh/config:第2行:错误的配置选项:addkeystagent/home/agaidis/.ssh/config:第3行:错误的配置选项:usekeychain/home/agaidis/.ssh/config:终止,2个错误的配置选项致命:无法从远程存储库读取。请确保您具有正确的访问权限,并且存储库存在。
~/.ssh/config
文件中删除无效选项。删除粘贴在您的问题中的所有四条指令应该没问题。谢谢!那真的救了我。