我正在尝试通过ssh克隆私有github repo。
我已经用keygen生成了一对密钥,它们存储在。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: Permission denied
表示您尝试执行/usr/bin/ssh
,但您没有ssh程序的执行权限。
为了解决这个问题,运行以下命令:
chmod +x /usr/bin/ssh
为ssh可执行文件添加执行权限。
还要确保你已经上传了你的公钥到GitHub。
第二个错误也是权限问题:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 警告:无保护私钥文件!/home/nonroot/.ssh/id_rsa. permission . 0644酒吧太开放了。它要求您的私钥文件不能被其他人访问。此私钥将被忽略。
这意味着您机器上的其他人有权查看您的私钥。
这个问题可以使用chmod -R 700 ~/.ssh
修复。
此命令更改.ssh
目录的权限,使其他人无法访问该目录。