【问题标题】:Permission denied to Git despite valid SSH authentication尽管有效的 SSH 身份验证,但 Git 的权限被拒绝
【发布时间】:2021-05-20 03:50:09
【问题描述】:

今天早上我的 Windows git 客户端让我大吃一惊

> git pull

git@github.xxx.net: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

尽管使用 GitHub 的 SSH 身份验证有效,但仍会发生这种情况

>ssh git@github.xxx.net
PTY allocation request failed on channel 0
Hi dzieciou! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.xxx.net closed.

这可能是原因吗?我拥有访问此特定项目的所有必要权限。

【问题讨论】:

  • 你使用git@github.com:username/repo url 作为远程吗?您是否检查过您可以访问浏览器中的存储库?
  • @MaartenDev 这是 GitHub Enterprise,但没关系:URL 是正确的 git@github.xxx.net:organization/repo.git,我可以从 Web 浏览器和 Ubuntu 访问这个 repo。看起来像 Git 客户端和 Windows 上的 SSH 之间的一些集成问题。昨天还可以。
  • 您是否尝试过调试步骤:docs.github.com/en/github/authenticating-to-github/… 以验证是否使用了正确的密钥文件?

标签: windows git ssh


【解决方案1】:

首先,检查输入后git pull 的作用

set GIT_SSH_COMMAND="ssh -Tv"

并与ssh -Tv git@github.xxx.net比较

其次,确保没有其他GIT 环境变量。列出它们:

set GIT

这是为了检查是否有一个 GIT_SSH 环境变量,引用一个不同的 ssh 作为你在 Windows 版 Git 中默认使用的那个。

【讨论】:

    猜你喜欢
    • 2022-01-02
    • 2019-01-21
    • 1970-01-01
    • 1970-01-01
    • 2017-12-15
    • 2013-01-05
    • 2020-12-02
    • 1970-01-01
    • 2014-12-17
    相关资源
    最近更新 更多