git - "You' 已成功验证,但 GitHub 不提供 shell 访问” 在运行完所有 ssh 设置步骤后

标签 git ubuntu ssh

我很困惑。我正在尝试获取 git clone命令工作,但它一直说:

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.
不过,我觉得我已经完成了所有正确的步骤。
1-我已经安装了 git。当我做 git --version它说git version 2.17.1 .
2- 我也做过ssh-keygen -t ed25519 -C "my_email@example.com"并查看 id_ed25519.pub我的 .ssh 中的文件文件夹。
3- 我已经完成了eval "$(ssh-agent -s)"ssh-add ~/.ssh/id_ed25519并添加了复制 id_ed25519.pub 的内容作为 SSH key 进入我的 Github。
然后当我这样做ssh -T git@github.com我得到:
The authenticity of host 'github.com (140.82.114.4)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,140.82.114.4' (RSA) to the list of known hosts.
Hi nightfarrow! You've successfully authenticated, but GitHub does not provide shell access.
Please make sure you have the correct access rights
如果我尝试做sudo git clone --recursive git@github.com:shubham-goel/ucmr.git我明白了fatal: Could not read from remote repository.错误。
此时可能是什么问题?如何诊断这个问题?谢谢你。

最佳答案

您看到问题是因为您使用的是 sudo .
当您使用 SSH key 时,它来自用户的主目录,而当您使用 SSH 代理时,它来自环境。当您使用 sudo ,您更改了当前用户,因此 key 来自 root 的主目录,而 sudo ,默认情况下,出于安全原因清除环境。因此,无法访问您的 key ,您的操作将失败。
除非您有令人信服的理由,否则应避免使用 sudo在这里,因为它不是必需的。如果您确定需要它并且您确定 PATH 中没有任何内容或其他可能存在安全风险的环境,您可以尝试使用 sudo -E ,这将避免清除环境,因此让您的 SSH 代理与您的克隆一起工作。

关于git - "You' 已成功验证,但 GitHub 不提供 shell 访问” 在运行完所有 ssh 设置步骤后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65524600/

相关文章:

git - 为 Git 中的特定分支应用钩子(Hook)

git - 查看较旧的失败提交消息

Git 说 "new commits"但在文件夹中找不到

python - 操作系统错误 : [Errno 13] when running CGIHTTPServer

python - 使用 Paramiko 作为服务器

linux - 生成要在不同计算机上使用的 SSH key

mysql - 如何通过两个SSH主机连接MySQL数据库

svn - GIT-SVN 克隆命令执行无误但本地主分支丢失

Python、Linux : How to delete unicode files?

ubuntu - 在 Ubuntu 12.04 上的 Visual Studio Code 中仅打开特定文件夹