首页 > 解决方案 > 如何修复 Permission denied (publickey) onGitlab?

问题描述

我在 Gitlab 上有一个项目,最近几天我一直在使用它!

但几天后,一切都过去了!我在 Gitlab 项目设置中添加了我的家用 PC ssh 密钥,但现在我想git pull用于接收我家用 PC 中的新更改,向我显示此错误:

10:47 AM    Update failed
                    Permission denied (publickey).
                    Could not read from remote repository.

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

10:47 AM    Update canceled

Gitlab ssh 密钥图像: 在此处输入图像描述

我该如何解决?

标签: gitlab

解决方案


GitHub 无法对您进行身份验证。所以,要么你没有设置 SSH 密钥,因为你没有在你的机器上设置一个,要么你的密钥没有与你的 GitHub 帐户相关联。

您还可以使用 HTTPS URL 而不是 SSH/git URL,以避免处理 SSH 密钥。这是 GitHub 推荐的方法。

此外,GitHub 有一个专门针对该错误消息的帮助页面,并更详细地解释了您可以检查的所有内容。

我知道这个问题。添加 ssh 密钥后,也将 ssh 密钥添加到 ssh 代理(来自官方文档https://help.github.com/articles/generating-ssh-keys/

ssh-agent -s
ssh-add ~/.ssh/id_rsa

之后,一切正常,git可以查看正确的密钥,之前不能。


推荐阅读