Autossh 是一个用来监控 SSH 链接,并自动进行重连的工具。类似 rstunnel (Reliable SSH Tunnel),采用 C 语言开发,安装简单,特别适合多个主机的连接。
```
$ sudo apt-get install gcc make
$ wget http://fossies.org/linux/privat/autossh-1.4e.tgz
$ tar -xf autossh-1.4e.tgz
$ cd autossh-1.4e
$ ./configure
$ make
$ sudo make install
```
`root#/usr/bin/sudo -u test /usr/local/bin/autossh -M 10904 -fN -o "PubkeyAuthentication=yes" -o "StrictHostKeyChecking=false" -o "PasswordAuthentication=no" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 47.254.17.153:5000:192.168.2.233:5000 test@47.254.17.153-p22`