克隆git存储库时权限被拒绝

cor*_*ryj 4 linux git github amazon-ec2 git-clone

所以我只是设置了一个Amazon EC2实例.并安装了git ..

sudo yum install git
Run Code Online (Sandbox Code Playgroud)

然后我用github设置我的ssh密钥.现在,当我尝试将我的repo克隆到/ var/www/html文件夹时,我收到此错误..

fatal: could not create work tree dir 'example.com'.: Permission denied
Run Code Online (Sandbox Code Playgroud)

当我以root身份运行时......

Cloning into 'example.com'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

但我确保我的github公钥与我的〜/ .ssh/id_rsa.pub键匹配.这里有什么我想念的吗?

nos*_*nos 12

您的第一个错误是因为您的用户无权写入/ var/www/html.您可以授予您的用户权限.

以root用户身份运行时出现的第二个错误可能是您的用户主目录中有ssh密钥,而不是/root/.ssh/,或者您的.ssh目录或〜/ .ssh/id_rsa.pub密钥文件改进者权限.〜/ .ssh /应该有权限位0700,并且应该有〜/ .ssh/id_rsa.pub,例如0600