Github SSH工作但使用ssh克隆失败

问题描述 投票:2回答:2

我在使用ssh克隆git存储库时遇到了一个奇怪的问题。我有ssh设置:

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

我正在使用正确的克隆URL并且可以访问我想要克隆的repo。但得到错误:

➤ git clone [email protected]:<some-org>/<repo>.git
Cloning into 'project'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

没有其他消息来调试我的ssh设置或git配置有什么问题。

git github ssh git-config
2个回答
3
投票

我发现我的.gitconfig中有一个条目用https代替ssh。

[url "https"]
    insteadOf = git

我可能在使用某些工具时意外添加了此条目。所以clone命令实际上是使用url [email protected]:<some-org>/<repo>.git

.gitconfig删除上述条目后问题得到解决。


0
投票

在我的情况下,我不得不删除〜/ .ssh / known_hosts文件,以便在克隆时,它将重新创建该文件。在此之后,它奏效了

© www.soinside.com 2019 - 2024. All rights reserved.