SSH 本地端口转发 --- VM中ubuntu service 可被 Windows 访问

before:

Windows

├──X──► 192.168.165.128:7156

Ubuntu
 
 
 
after:
Windows
localhost:17156


SSH Tunnel

Ubuntu
127.0.0.1:7156

 

 why?

NAT 允许内部机器主动访问外部,但不允许外部主动访问内部。端口转发就是给 NAT 增加一条规则,告诉它收到某个端口的请求时应该转发给哪台内部机器。

image

 

image

 

 

image

 

image

 

 

image

 

***@***-VMware-Virtual-Platform:~$ hostname -I
192.168.165.128 172.20.0.1 172.17.0.1 172.19.0.1 172.18.0.1 172.21.0.1 fd00::1

find ubuntu-ip-address:192.168.165.128

 
 
ssh -N \
-L 127.0.0.1:17156:127.0.0.1:7156 \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=30 \
[ubuntu-user-name]@[ubuntu-ip-address]
 
 
 
 
 
 
posted @ 2026-07-28 15:40  PanPan003  阅读(3)  评论(0)    收藏  举报