openssh 从7.2版本开始,添加了对PorxyJump的支持,PorxyJump选项主要用于多级跳板机的支持

Changes since OpenSSH 7.2
=========================

New Features
------------

 * ssh(1): Add a ProxyJump option and corresponding -J command-line
   flag to allow simplified indirection through a one or more SSH
   bastions or "jump hosts".

跳板机主要是因为安全管控性要求以及安全审计的需求,以便将网络环境隔离同时将所有到机房的操作行为记录下来.

那我们来看看ProxyJump如何配置:

Host jumper_1
    Hostname 192.168.56.10
    Port 22
    User ubuntu
    IdentityFile ~/.ssh/id_rsa

Host jumper_2
    Hostname 192.168.56.20
    Port 22
    User ubuntu
    IdentityFile ~/.ssh/id_rsa
    ProxyJump jumper_1

上面的配置意思是, 我们 ssh jumper_2 需要通过 jumper_1 跳板机之后才能正常登陆到 jumper_2.

如果有更多的跳板机,可以在 ProxyJump 选项的地方以逗号分割,按跳板顺序配置,比如: ProxyJump jumper_1,jumper_2,jumper_3

这样的好处是, 我们对中间的很多跳板环节的操作简化为openssh client自动完成,当然前提还是需要将密码登陆切换未密钥登陆.

如果服务器 ssh server 的 /etc/ssh/sshd_config 的选项 AllowTcpForwarding=no 上述选项将不能生效.

参考连接

【腾讯云】境外1核2G服务器低至2折,半价续费券限量免费领取!
https://cloud.tencent.com/act/cps/redirect?redirect=1068&cps_key=e4b50f6c64a4480367f8a8d16fd07c5a&from=console

标签: openssh, proxyjump, .ssh, config

添加新评论