ssh隧道转发

 test1 test2 test3 其中,test1和test2不能互通,test1和test3,test2和test3都可以互通

实现需求,使test1 通过ssh连上test2

test1:192.168.134.11

test2:192.168.134.12

test3:192.168.134.13

ssh -fNg -L 192.168.134.11:6668:192.168.134.12:22 [email protected]

参数解释
-L 本地端口转发
-f 后台转发
-g 网关作用,让其它主机也能访问端口
-N 不执行ssh远程指令

把192.168.134.12 的22端口映射到 192.168.134.11的6668端口

 或者

ssh -Ng -L test1:6668:test2:22 test3

 1.运行该命令

[root@test1 ~]# ssh -Ng -L 192.168.134.11:6668:192.168.134.12:22 [email protected]
[email protected]'s password:


2.此时在test1上新开一个终端,连上test2

[root@test1 ~]# ssh 192.168.134.11 -p 6668
Last login: Fri Dec  8 10:52:11 2023 from 192.168.134.11
[root@test2 ~]#

你可能感兴趣的:(ssh,运维)