[Unit] Description=SSH Tunnel After=network-online.target StartLimitIntervalSec=3610 StartLimitBurst=20 [Service] ExecStart=/usr/bin/screen -Dm -S sshtun /usr/bin/ssh -o ServerAliveInterval=60 -R22222:localhost:22 myuser@myserver "ssh localhost -gL2222:localhost:22222" ExecStop=/usr/bin/screen -S sshtun -X stuff "exit\015" ExecStop=/usr/bin/screen -wipe WorkingDirectory=/home/myuser Restart=always RestartSec=180s User=myuser Group=myuser [Install] WantedBy=multi-user.target