sshd-防断内网穿透

Aug 3, 2018

做系统测试,经常需要做内网穿透, 但是有时候经常会断线, 需要设置一个定时任务, 在断开的时候重连.定时任务内容如下:

0 */1 * * * ps aux|grep ssh|grep 8080|grep -v grep || ssh -qTfnN -R 0.0.0.0:8080:localhost:8080 ssh-out.net.com

将本地的 8080 映射到远程的 8080 ! 这样访问远程的 8080 就是访问本地的 8080 ! 注意: 需要配置远程主机的 sshd 的配置文件: /etc/ssh/sshd_config !

ClientAliveInterval 60
ClientAliveCountMax 3

配置 60s 的心跳, 否则任然会掉线

(完)