【问题标题】:GitHub SSH access not workingGitHub SSH 访问不起作用
【发布时间】:2016-11-03 00:18:49
【问题描述】:

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

不知何故,当我尝试将存储库克隆到服务器时,它工作了一次。代码运行正常,我退出服务器。今天,我们发布了代码更新,我想手动将代码部署到服务器,所以我 ssh 到服务器并尝试使用git 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.

但是当我尝试从存储库中提取时,我不断收到以下错误消息:

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

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

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

感谢任何帮助和建议!


更新:

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

【问题讨论】:

    标签: linux git ubuntu github ssh


    【解决方案1】:

    我遇到了完全相同的问题。 对我来说有效的是

    1. 转到您已克隆并想要拉取的 github 上的 repo
    2. 在代码下载选项下复制 SSH 链接
    3. 在终端中输入以下命令 --> git remote set-url origin paste_SSH_link

    【讨论】:

      【解决方案2】:

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

      github doc for reference

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-12-20
        • 2018-03-17
        • 2017-04-21
        • 1970-01-01
        • 1970-01-01
        • 2017-11-08
        • 1970-01-01
        • 2021-07-28
        相关资源
        最近更新 更多