sudo apt install -y autossh
set up logging:
echo 'export AUTOSSH_LOGFILE="$HOME/autossh.log"' >> ~/.bashrc
autossh -M 20000 -fNn your_public_server -R 1234:localhost:22 -C
-M
: the monitor port-f
: run in background-N
: no execution, just for forwarding-n
: redirect stdin to /dev/null-T
: disable pseudo terminal emulation-R
:-C
: compress all dataautossh -f -nNT -i ~/keypair.pem -R 2000:localhost:22
crontab -e
enter the following
@reboot sleep 300 && autossh -M 20000 -f -Nnt -R 2201:localhost:22 <servername> -C