Git ssh无法解析主机名

4
如果我想通过SSH克隆Git存储库,会出现以下情况:
ssh: Could not resolve hostname bitbucket.org: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

我需要使用代理连接到互联网。(proxy:8080)

在Git中,我可以通过以下方式轻松设置HTTP和HTTPS代理:

git config --global http.proxy http://proxy:8080/
git config --global https.proxy http://proxy:8080/

这在 SSH 中如何实现?

我遇到了同样的问题。重启电脑解决了它。 - mbomb007
2个回答

4
SSH不能与HTTP/HTTPS代理一起使用。如果您的代理支持SOCKS,您可以使用像tsocks或socksify这样的包装器,或者像redsocks这样的重定向工具通过SOCKS使用git。这些是Linux的选项;在Windows上,Widecap之类的工具可能会有所帮助。下面是更全面的适用工具概述:https://en.wikipedia.org/wiki/Comparison_of_proxifiers 另外,Git也支持HTTP,BitBucket也支持HTTP,据我所知。因此,尝试使用https://代替URL可能是值得的。例如:https://youruser@bitbucket.org/youruser/yourrepository.git

2

我遇到了类似的问题,最终来到了这里。在我的情况下,我的一个本地GitLab项目在推送/拉取时出现以下错误。同一组下的其他GitLab项目正常工作。

ssh: Could not resolve hostname gitlab.com: nodename nor servname provided, or not known.

修复:

在文件<PROJECT_FOLDER>/.git/config中,url的格式为url = ssh://git@gitlab.com

将url中的ssh://删除后对我有用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接