Can';t使用SSH克隆GitHub Repo

Can';t使用SSH克隆GitHub Repo,git,ubuntu,github,ssh,Git,Ubuntu,Github,Ssh,我正在尝试通过ssh克隆私有github repo 我已经使用keygen生成了一对密钥,它们存储在非root用户主目录中的.ssh中 /home/nonroot/.ssh 但是,当我尝试时: git clone git@github.com:user/repo.git 我得到: Cloning into 'discord-bot'... git@github.com: Permission denied (publickey). fatal: Could not read from rem

我正在尝试通过ssh克隆私有github repo

我已经使用keygen生成了一对密钥,它们存储在非root用户主目录中的.ssh中

/home/nonroot/.ssh
但是,当我尝试时:

git clone git@github.com:user/repo.git
我得到:

Cloning into 'discord-bot'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
下面,我试过:

ssh -T git@github.com
得到:

bash: /usr/bin/ssh: Permission denied
我该怎么办

运行Ubuntu 20.04

bash:/usr/bin/ssh:权限被拒绝

表示您尝试执行
/usr/bin/ssh
,但您没有ssh程序的执行权限

要解决此问题,请运行以下命令:

chmod +x /usr/bin/ssh
将执行权限添加到ssh可执行文件

还要确保您已将公钥上载到GitHub


第二个错误也是权限问题:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@警告:未受保护的私钥文件!@“/home/nonroot/.ssh/id_rsa.pub”的权限0644太开放。其他人不能访问您的私钥文件。此私钥将被忽略

这意味着您计算机上的其他人有权查看您的私钥

可以使用
chmod-R 700~/.ssh
修复此问题


此命令更改
.ssh
目录的权限,以使其他人无法访问它。

此命令修复了ssh权限被拒绝的问题。但是,现在当我尝试在我的github上克隆某些内容时,我会得到
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@“/home/nonroot/.ssh/id_rsa.pub”的权限0644太开放。其他人不能访问您的私钥文件。此私钥将被忽略。
使用
chmod-R 700~/.ssh
。在
chmod-R 700~/.ssh
之后,我收到以下错误:
加载密钥/home/nonroot/.ssh/id\u rsa.pub”:格式无效git@github.com:权限被拒绝(公钥)。致命:无法从远程存储库读取