Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github SSH工作,但使用SSH克隆失败_Git_Github_Ssh_Git Config - Fatal编程技术网

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

Github SSH工作,但使用SSH克隆失败,git,github,ssh,git-config,Git,Github,Ssh,Git Config,我在使用ssh克隆git存储库时遇到了一个奇怪的问题。我有ssh设置: ssh -T git@github.com Hi yusufali2205! You've successfully authenticated, but GitHub does not provide shell access. 我正在使用正确的克隆url,并且有权访问我要克隆的repo。但是得到错误: ➤ git clone git@github.com:<some-org>/<repo>.gi

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

ssh -T git@github.com
Hi yusufali2205! You've successfully authenticated, but GitHub does not provide shell access.
我正在使用正确的克隆url,并且有权访问我要克隆的repo。但是得到错误:

➤ git clone git@github.com:<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.
➤ git克隆git@github.com:/.git
克隆到“项目”。。。
权限被拒绝(公钥)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并且存储库存在。

没有其他消息可以调试ssh设置或git配置的错误。

我发现我的
.gitconfig
中有一个条目正在用https替换ssh

[url "https"]
    insteadOf = git
我可能在使用某些工具时意外添加了此条目。所以clone命令实际上使用的是url
https@github.com:/.git


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

在我的情况下,我必须删除~/.ssh/known_hosts文件,以便在克隆时,它将重新生成该文件。在这之后,它起了作用,我也遇到了同样的问题,我尝试了一些东西,我得到了它。转到您的.ssh目录,用记事本打开文件known_hosts,它的开头有“github.com”。。。在github.com的开头插入SSH:。这对我有用