博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ssh 网关_通过网关直接SSH到主机的内部IP
阅读量:2530 次
发布时间:2019-05-11

本文共 2671 字,大约阅读时间需要 8 分钟。

ssh 网关

We have many hosts with internal/LAN IPs like 10.0.3.* behind a gateway and the hosts with LAN IPs can connect to the Internet . We used iptables to so that users from hosts with Internet connections can to the gateway’s forwarded port to log on the internal hosts. However, there should be rules added for these hosts and the users need to connect to these non-standard (not 22) ports of the gateway that may be blocked by firewalls of their .

网关后面有许多具有内部/ LAN IP(例如10.0.3。*)的主机,具有LAN IP的主机可以连接到Internet。 我们使用iptables将以便具有Internet连接的主机中的用户可以到网关的转发端口以登录内部主机。 但是,应该为这些主机添加规则,并且用户需要连接到网关的这些非标准(非22)端口,这些端口可能会被其的防火墙阻止。

Is there any other methods to support this? We do not want VPN yet since only SSH is needed most of the time and we do not like to be too open to the Internet yet.

还有其他方法可以支持这一点吗? 我们不想要VPN,因为大多数时候只需要SSH,而且我们不希望对Internet过于开放。

My solution is to use a SSH tunnel as the proxy to SSH to the internal hosts. This is set by the users themselves on their own side.

我的解决方案是使用SSH隧道作为SSH到内部主机的代理。 这由用户自己设置。

Assumptions and requirements:

假设和要求:

1. You, the user, are using a environment on your machine, say user.example.org .

2. You can to the gateway, say gateway.example.org, with your username. You can use other usernames, non-standard port, or forward the 22 port of gateway to an internal host/VM for security reason. We use the most simple configuration for simplicity of the introduction.
3. On the gateway or the host that you can ssh to as a proxy, is installed.

1.您(用户)正在您的计算机上使用环境,例如user.example.org。

2.您可以使用用户名以无网关,例如gateway.example.org。 出于安全原因,您可以使用其他用户名,非标准端口或将网关的22端口转发到内部主机/ VM。 为了简化介绍,我们使用最简单的配置。
3.在可以ssh作为代理的网关或主机上,安装了 。

Now, add these 2 lines to your ~/.ssh/config (make its attributes 700) on user.example.org:

现在,将这两行添加到user.example.org上的~/.ssh/config (使其属性为700):

Host 10.0.3.*  ProxyCommand ssh -q gateway.example.org nc %h %p

Then, on user.example.org, you can directly ssh to internal hosts, such as:

然后,可以在user.example.org上直接SSH到内部主机,例如:

ssh 10.0.3.100

The SSH client will first run ssh -q gateway.example.org nc 10.0.3.100 22 which log on gateway.example.org and runs nc 10.0.3.100 22 on the gateway. The nc on the gateway will redirect all input from the SSH client on user.example.org to 10.0.3.100:22 to which the sshd daemon on 10.0.3.100 listens. That is, gateway.example.org works as the proxy for the SSH connection and the users can connect to the internal IPs “directly”.

SSH客户端将首先运行ssh -q gateway.example.org nc 10.0.3.100 22 ,后者登录gateway.example.org并在网关上运行nc 10.0.3.100 22 。 网关上的nc会将来自user.example.org上的SSH客户端的所有输入重定向到10.0.3.100上的sshd守护程序侦听的10.0.3.100:22。 也就是说,gateway.example.org充当SSH连接的代理,用户可以“直接”连接到内部IP。

翻译自:

ssh 网关

转载地址:http://rnlwd.baihongyu.com/

你可能感兴趣的文章
经典排序算法回顾:选择排序,快速排序
查看>>
BZOJ2213 [Poi2011]Difference 【乱搞】
查看>>
c# 对加密的MP4文件进行解密
查看>>
AOP面向切面编程C#实例
查看>>
访问修饰符、封装、继承
查看>>
更换pip源到国内镜像,提升pip下载速度.
查看>>
Kendo MVVM 数据绑定(七) Invisible/Visible
查看>>
插入返回ibatis 的selectKey 实现插入数据后获得id
查看>>
解决win7下打开Excel2007,报“向程序发送命令时出现问题”的错误
查看>>
Win form碎知识点
查看>>
避免使用不必要的浮动
查看>>
第一节:ASP.NET开发环境配置
查看>>
sqlserver database常用命令
查看>>
rsync远程同步的基本配置与使用
查看>>
第二天作业
查看>>
访问属性和访问实例变量的区别
查看>>
Spring MVC 异常处理 - SimpleMappingExceptionResolver
查看>>
props 父组件给子组件传递参数
查看>>
【loj6038】「雅礼集训 2017 Day5」远行 树的直径+并查集+LCT
查看>>
十二种获取Spring的上下文环境ApplicationContext的方法
查看>>