如果之前有人问过这个问题,我很抱歉,但我目前正试图找到一个解决方案,允许我们建立类似于RDP网关如何工作的SSH连接。对于那些不熟悉的人,RDP网关允许您从本质上通过另一台服务器代理RDP连接。远程桌面将透明地与RDP网关服务器进行身份验证,并从那里建立到端点服务器的连接,允许您通过私有IP地址或内部DNS名称引用端点服务器,从而限制您的暴露。
目前,我想的是通过SSH设置端口转发,以便我们需要访问隧道代理后面的每个服务器都位于由中间服务器转发的不同端口上。然而,这并不是一个最优的解决方案,所以我想知道是否有更好的方法来做到这一点。
发布于 2019-07-25 06:49:57
在SSH术语中,您经常谈到堡垒宿主或跳转服务器 --这是一台接受传入SSH连接的机器(通常在DMZ中),然后您可以从这台机器与实际管理的系统建立SSH连接。
==> | Server1 |
_________ ___________ / ---------
| user PC | ===(SSH on port 22)===> | jump host | ===(SSH on port 22)== ==+> | Server2 |
_________ ___________ \ _________
==> | Server3 |通常,为了提高安全性,跳转服务器将需要双因素身份验证,并且/或只在建立VPN连接后才接受传入的SSH会话。
与第一次登录到跳转主机和从命令提示符开始第二次SSH会话不同,OpenSSH允许您在单个命令中配置
我更喜欢在我的~/.ssh/config中显式设置每个主机的短别名。这样,我就不需要使用任何命令行标志,只需输入更少的内容,使用ssh Destination就可以了。
Host jumphost
Hostname jumphost.example.com
User serverfault
ForwardAgent yes
AddKeysToAgent yes
UseKeychain yes # Specific to OS X
IdentityFile ~/.ssh/id_rsa.jumphost
Host server1
Hostname server1.int.example.com
User hbruijn
ForwardAgent yes
AddKeysToAgent yes
UseKeychain yes # Specific to OS X
IdentityFile ~/.ssh/id_rsa.int.example.com
ProxyJump jumphostProxyJump是一个相对较新的设置,我发现使用它比使用ProxyCommand更直观。现在,ssh server1将完全满足您的需要,首先使用serverfault@jumphost.example.com作为第一跳创建一个会话,您可以选择使用不同的ssh键和不同的用户名hbruijn@server1.int.example.com将其导入下一跳。
您还可以直接从命令行中使用ProxyJump命令:
ssh -J serverfault@jumphost.example.com hbruijn@server1.int.example.com在这个问答中讨论了另一种方法
发布于 2019-07-25 06:45:50
规范的解决方案是部署IPv6 (和/或虚拟专用网),并避免这种解决办法,但如果您现在不能这样做,那么它被称为跳转盒或堡垒主机或类似的术语。这只是一台你安装的机器,你的用户可以登录到ssh,然后ssh进一步进入内部主机,这个盒子可以访问网络。ssh命令甚至有一个命令行选项,它可以自动通过跳转主机进行连接。
-J destination
Connect to the target host by first making a ssh connection to
the jump host described by destination and then establishing a
TCP forwarding to the ultimate destination from there. Multiple
jump hops may be specified separated by comma characters. This
is a shortcut to specify a ProxyJump configuration directive.
Note that configuration directives supplied on the command-line
generally apply to the destination host and not any specified
jump hosts. Use ~/.ssh/config to specify configuration for jump
hosts.https://serverfault.com/questions/976611
复制相似问题