內部 IP:192.168.131.219 Server A
外部 IP:140.111.74.17 Server B
外部 IP:1.161.49.150 Server C
1. 在 Server A 上執行
# ssh -NfR 2222:localhost:22 root@140.111.74.17
# ssh -BfR 2222:192.168.131.219 root@140.111.74.17
-N Do not execute a remote command.
-f Requests ssh to go to background just before command execution.
-R [bind_address:]port:host:hostport
2. 在 Server B 上執行
# netstat -antp | grep 2222
tcp 0 0 127.0.0.1:2222 0.0.0.0:* LISTEN 519/sshd: root
tcp6 0 0 ::1:2222 :::* LISTEN 519/sshd: root
# ss -antp | grep 2222
LISTEN 0 128 127.0.0.1:2222 *:* users:((“sshd”,pid=519,fd=9))
LISTEN 0 128 ::1:2222 :::* users:((“sshd”,pid=519,fd=8))
3. 在 Server C 上想要連線到 Server A,先連線到 Server B
# ssh root@140.111.74.17
# ssh -p 2222 root@127.0.0.1