linux - GitHub SSH 访问无效

标签 linux git ubuntu github ssh

我在我们组织下的 github 上创建了一个新用户,将用于自动部署。我关注了关于 https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux 的文章.

不知何故,当我尝试将存储库克隆到服务器时,它成功了一次。代码运行正常,我退出了服务器。今天,我们发布了代码更新,我想手动将代码部署到服务器,所以我 ssh 进入服务器并尝试使用 git pull pull 存储库。它给了我Permission denied 错误。经过一些调试后,我意识到 ssh-agent 没有运行。所以我执行了以下命令:

eval "$(ssh-agent -s)"
ssh-add .ssh/id_rsa_staging

现在,当我尝试 ssh -T git@github.com 时,我看到了欢迎消息:

Hi *****! You've successfully authenticated, but GitHub does not provide shell access.

但是当我尝试从存储库中 pull 时,我不断收到此错误消息:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我检查了存储库,用户对其具有 访问权限。我仔细检查了 github 和服务器上的 key 是否匹配,是的。我尝试生成新 key 。我尝试使用 ssh/config 文件。没有任何帮助...

感谢任何帮助和建议!


更新:

所以我发现 git clone 命令工作正常,但即使我在 git clone 之后立即尝试 git pull,它也会给出错误。

最佳答案

如果您使用 sudogit pull/push 到远程,您需要确保使用 sudo 生成 SSH key 。否则,您将不会使用最初生成的相同 key 。

github doc for reference

关于linux - GitHub SSH 访问无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38130965/

相关文章:

mysql - SELECT INTO OUTFILE 权限被拒绝,但用户可以写入目录

git - 如何添加新的根提交?

windows - Git pull 随机挂起

PHP 脚本不在本地主机上运行

linux - Xampp 无法在 ubuntu 17.10 上启动

linux - 简单的轻量级 pop3 服务器

c - 如何捕捉pointermotion事件,将指针限制在一个区域内?

git color.ui 在 Ubuntu 14.10 上不起作用

通过 crontab ("Directory nonexistent"启动 PHP 脚本失败)

postgresql - 在 Ubuntu 上多次安装 Postgres