通过代理在 Linux 中通过 SSH 客户端连接到主机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15577300/
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
Connecting to host by SSH client in Linux by proxy
提问by Agus
I am really struggling with this.
我真的很挣扎。
My host (A) is behind a proxy/firewall (PF) and needs to connect to host H.
我的主机 (A) 在代理/防火墙 (PF) 后面,需要连接到主机 H。
The proxy has HTTP/FTP/SOCK proxy configured and I have no issue to configure in web browser, wget etc.
代理配置了 HTTP/FTP/SOCK 代理,我在 Web 浏览器、wget 等中配置没有问题。
But when I use...
但是当我使用...
ssh H //to connect my host
I have no success to pass over the proxy. It seems to try to connect directly instead of going via the PF.
我没有成功通过代理。它似乎尝试直接连接而不是通过 PF。
I am using Ubuntu 12.10.
我正在使用 Ubuntu 12.10。
采纳答案by Andy Ross
Check the docs for the ssh ProxyCommand
option. You can specify a command to run (for example, nc) to connect to a given host and port. For example, adding this to your .ssh/config might work to traverse a SOCKS5 proxy:
检查 sshProxyCommand
选项的文档。您可以指定要运行的命令(例如,nc)以连接到给定的主机和端口。例如,将其添加到您的 .ssh/config 可能有助于遍历 SOCKS5 代理:
ProxyCommand nc -x MY_PROXY_HOST:MY_PROXY_PORT %h %p
More detailed instructions are going to depend on your environment.
更详细的说明将取决于您的环境。
回答by Oleg S Kleshchook
There are several ways to do it. You can use nc or try wrappers like corkscrew. I'll describe way with wrapeer:
有几种方法可以做到。您可以使用 nc 或尝试像开瓶器这样的包装器。我将用 wrapeer 描述方式:
Firstly install corkscrew by apt-get
Then you need to specify ProxyCommand in your ./ssh/configfile (replace example-proxy.com and 8080 with your proxy host and port):
首先通过apt-get安装
corkscrew然后你需要在你的./ssh/config文件中指定ProxyCommand (用你的代理主机和端口替换example-proxy.com和8080):
Host *
ProxyCommand corkscrew example-proxy.com 8080 %h %p ~/.ssh/proxyauth
Your login credentials should be in ~/.ssh/proxyauth in format:
您的登录凭据应在 ~/.ssh/proxyauth 格式中:
login:password