github 通过 ssh (Windows) 看到错误的用户名

问题描述 投票:0回答:1

编辑:原来是Windows上git的一些问题。 该问题在 Linux 系统上未重现。

我正在尝试克隆我的 github 存储库。

我按照 官方 github 的说明设置 SSH 访问。密钥验证成功:

$ ssh -T [email protected]
Hi 1234ru! You've successfully authenticated, but GitHub does not provide shell access.

存储库网址看起来正确:

$ git remote get-url --push origin
[email protected]:1234ru/<my-repo>.git

clone
命令失败:

$ git clone [email protected]:1234ru/<myrepo>.git
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

我不明白为什么

ssh -T
响应OK而
git clone
同时被拒绝。

authentication github ssh push
1个回答
0
投票

整个问题是因为更改了 git 的

core.sshCommand
设置,其中包含显式用户名:

$ git config core.sshCommand
ssh -l 1234ru

这使得

git
命令使用
1234ru
用户名连接到Github,不是
git
用户名,因为它应该,这导致访问被拒绝。

仔细阅读错误信息其实就很清楚了:

1234ru@github.com:权限被拒绝(公钥)。

应该是git。如果不是,并且远程 URL 正确 - 请检查您的

core.sshCommand
(同时注意范围):

git config --show-scope core.sshCommand

如果看起来很奇怪,只需取消设置即可:

git config --unset core.sshCommand
© www.soinside.com 2019 - 2024. All rights reserved.