通过代理连接SSH [英] Connect with SSH through a proxy

查看:39
本文介绍了通过代理连接SSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我在这里做什么,所以如果你能帮助我,请记住这一点!

I have no real idea what I'm doing here so please bear that in mind if you can help me!

我正在尝试通过代理连接到我的虚拟服务器,但我无法连接,它只是挂起.我假设这是因为它没有通过我们的代理.

I am trying to connect to my virtual server through a proxy but I can't connect, it just hangs. I'm assuming this is because it's not getting through our proxy.

我在家里尝试过完全相同的方法,效果很好.我在 OSX 上使用终端连接.

I have tried exactly the same thing at home and it works perfectly. I'm on OSX using Terminal to connect.

谁能告诉我如何通过 SSH 访问代理?

Can anyone advise me how I can get through the proxy with SSH?

推荐答案

这里是如何做 Richard Christensen 的 answer 作为一个单行,无需文件编辑(用您自己的设置替换大写,PROXYPORT 通常为 80):

Here's how to do Richard Christensen's answer as a one-liner, no file editing required (replace capitalized with your own settings, PROXYPORT is frequently 80):

 ssh USER@FINAL_DEST -o "ProxyCommand=nc -X connect -x PROXYHOST:PROXYPORT %h %p"

您也可以对 scp 使用相同的 -o ... 选项,请参阅 我的超级用户回答.

You can use the same -o ... option for scp as well, see my superuser answer.

如果你在 OS X 中得到这个:

If you get this in OS X:

 nc: invalid option -- X
 Try `nc --help' for more information.

可能是您不小心使用了netcat的自制版本(您可以通过执行which -a nc 命令来查看--/usr/bin/nc 应首先列出).如果有两个,那么一种解决方法是指定所需 nc 的完整路径,例如 ProxyCommand=/usr/bin/nc ...

it may be that you're accidentally using the homebrew version of netcat (you can see by doing a which -a nc command--/usr/bin/nc should be listed first). If there are two then one workaround is to specify the full path to the nc you want, like ProxyCommand=/usr/bin/nc ...

对于CentOS nc 也有同样的invalid option --X 问题.connect-proxy 是一个替代方案,使用 yum 很容易安装并且有效 --

For CentOS nc has the same problem of invalid option --X. connect-proxy is an alternative, easy to install using yum and works --

ssh -o ProxyCommand="connect-proxy -S PROXYHOST:PROXYPORT %h %p" USER@FINAL_DEST

这篇关于通过代理连接SSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆