SSH反向隧道实现内网穿透

1、客户端配置

/home/tsingyundev/zyy

bind209.sh内容

ssh -fCNL *:1234:localhost:10022 localhost

 

 ssh209.sh内容

ssh -p1234 tsingyun@localhost

  

2、服务端配置(被访问端)

2.1 tsingyun.sh脚本

#/bin/bash
while true; do
ssh -CNR 10022:localhost:22 \
-o ServerAliveCountMax=3 \
-o ServerAliveInterval=10 \
-o StrictHostKeyChecking=no \
-i /home/tsingyun/id_rsa \
tsingyundev@192.168.12.201
ping -c 60 -i 3 127.0.0.1 > /dev/null 2>&1 &
done

2.2 注意设置开机启动和 互访公钥

生成公钥:
ssh-keygen

把公钥发送给服务端
ssh-copy-id -i ~/.ssh/id_rsa.pub 服务端用户名@IP

3、示意图

 

posted @ 2022-06-16 11:41  向往明天-tsingyun  阅读(95)  评论(0编辑  收藏  举报