Git Clone-致命:远程端意外挂起

Git Clone-致命:远程端意外挂起,git,github,ssh,Git,Github,Ssh,我正在通过ssh从Ubuntu笔记本电脑连接到虚拟机 在这个虚拟机中,我正在尝试用git克隆一个存储库: /home/httpd$ sudo git clone git@github.com:NexwayGroup/softgallery [sudo] password for jverstrynge: Cloning into 'softgallery'... Permission denied (publickey). fatal: The remote end hung up unexp

我正在通过ssh从Ubuntu笔记本电脑连接到虚拟机

在这个虚拟机中,我正在尝试用git克隆一个存储库:

/home/httpd$ sudo git clone git@github.com:NexwayGroup/softgallery
[sudo] password for jverstrynge: 
Cloning into 'softgallery'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我已经看到了这一点,解决方案建议使用以下内容修改git配置:

/home/httpd$ git config http.postBuffer 524288000
error: could not lock config file .git/config: No such file or directory
但是我得到了上面的错误。有人知道怎么解决这个问题吗

我已经使用github检查了连接,它看起来很好:

ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Enter passphrase for key '/home/jverstrynge/.ssh/id_rsa': 
Hi JVerstry! You've successfully authenticated, but GitHub does not provide shell access.
jverstrynge@devjverstrynge:/home/httpd$ 
你在跑步

sudo git clone
sudo以root用户身份运行该命令,但您的root用户可能没有您的私有SSH密钥。因此,无法建立连接


一种解决方案是以普通用户的身份运行git命令(不带sudo),或者,如果出于某种原因确实需要sudo,也可以为root用户添加SSH密钥。

一种可能的解决方案是在root用户的~/.SSH/config中设置git主机,并使用用户的SSH密钥,该用户具有git公钥和私钥。有点老套,但应该行得通

因此,将以下内容添加到
/root/.ssh/config

Host github.com
  Hostname github.com
  User jverstrynge
  IdentityFile  /home/jverstrynge/.ssh/id_rsa

然后您应该能够进行
sudogit克隆git@github.com:NexwayGroup/softgallery
由于sudo应该使用root用户的.ssh/config

您是否也尝试过通过sudo检查连接<代码>sudossh-Tgit@github.com?您正在通过sudo进行克隆。@itempo nice catch,我无法使用sudo中运行的sudoI访问github,因为它无法使用我的配置文件创建克隆目录。问题是,我们将/home目录的所有权从root改为jverstrynge,问题就解决了。不再需要使用sudo。由于安全原因,这可能会很危险。使用这些权限,您可以删除和替换属于其他用户的主目录。另外,你为什么要克隆到家里?如果确实需要,您可以创建repo的空目录作为根目录,设置写入权限,然后克隆到其中。当然,这取决于您的具体设置是否真的有必要。