$ 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
autossh -M 5680 -NfR 1235:localhost:22 root@外网ip -p外网端口
生成密钥
$ ssh-keygen ...(一直按Enter,最后在~/.ssh/下生成密钥) $ ls ~/.ssh/ id_rsa id_rsa.pub known_hosts
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host