当前位置:网站首页>Implementing springboard agent through SSH port forwarding configuration

Implementing springboard agent through SSH port forwarding configuration

2022-06-27 13:38:00 So stupid

SSH Port forwarding needs to be modified /etc/ssh/sshd_config The configuration file , take GatewayPorts It is amended as follows yes

Parameter interpretation :

-f The background to perform ssh Instructions
-C Allow compression of data
-N Do not execute remote instructions
-R Will remote host ( The server ) Forward a port of to the specified port of the specified machine on the local side
-L Local port forwarding
-D Dynamic port forwarding

A short edition : Local port forwarding ( It's equivalent to a forward proxy ), Local monitoring 16379 port , take 16379 Port traffic is forwarded to 6379 port

ssh -fCNL *:16379:localhost:6379 localhost

SSH Reverse tunneling ( Remote port forwarding ) example

image-20220214213238533

  1. server Configuration of
#  take Server Of 22 The traffic of port 1 is forwarded to the springboard machine 2 Of 5555 port 
ssh -fCNR   Springboard machine 2:5555:localhost:22  [email protected] Springboard machine 2
  1. Springboard machine 2 Configuration of
ssh -fCNR  Springboard machine 1:5555:localhost:8888 [email protected] Springboard machine 1
  1. Springboard machine 1 Configuration of
#  Forward agency 
#  Local monitor 1234 Port traffic is forwarded to the local 8888 port 
ssh -fCNL  *:1234:localhost:8888 localhost

PC1 On

ssh -p 1234 [email protected] Springboard machine 1

Finally connected to server Of 22 On port

shortcoming : such ssh Backlinks will be closed due to timeout , If it is closed, the channel from the external network to the internal network cannot be maintained .

resolvent : Use autossh To connect .
Reverse proxy

autossh -M 9999 ssh -fCNR   Springboard machine 1:5555:localhost:22  localhost

-M Parameters , Used to monitor ssh The state of , If after the port , from 9999 Port send message , And then reconnect .

原网站

版权声明
本文为[So stupid]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202161637063323.html