Git ssh 无法解析主机名

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23470348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:01:08  来源:igfitidea点击:

Git ssh could not resolve hostname

gitsshproxy

提问by Niklas

If I want to clone a Git repository via SSH, I get:

如果我想通过 SSH 克隆一个 Git 存储库,我会得到:

ssh: Could not resolve hostname bitbucket.org: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

I need to use a proxy to connect to the internet. (proxy:8080)

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

In Git I can easily set the HTTP and HTTPS proxy via:

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

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

How can this be achieved for SSH?

SSH 如何实现这一点?

回答by Jan Krüger

SSH doesn't work with an HTTP/HTTPS proxy. If your proxy supports SOCKS, you may be able to use git via SOCKS using a wrapper like tsocks or socksify or a redirection tool like redsocks. Those are options for Linux; on Windows maybe something like Widecap will help. Here's a more comprehensive overview of tools that may be suitable: https://en.wikipedia.org/wiki/Comparison_of_proxifiers

SSH 不适用于 HTTP/HTTPS 代理。如果您的代理支持 SOCKS,您可以通过 SOCKS 使用 git,使用包装器(如 tsocks 或 socksify)或重定向工具(如 redsocks)。这些是 Linux 的选项;在 Windows 上,Widecap 之类的东西可能会有所帮助。以下是可能适用的工具的更全面概述:https: //en.wikipedia.org/wiki/Comparison_of_proxifiers

Alternatively, Git supports HTTP, too, and so does BitBucket, as far as I know. Hence, it might be worth trying the URL with https://instead. Example: https://youruser@bitbucket.org/youruser/yourrepository.git

或者,据我所知,Git 也支持 HTTP,BitBucket 也是如此。因此,可能值得尝试使用 URL https://。示例:https:// youruser@bitbucket.org/ youruser/ yourrepository.git