[Unit] Description=Setup a secure tunnel to %I After=network.target [Service] Environment="TARGET_PORT=22" EnvironmentFile=/home/lx/.config/secure-tunnel/%i.conf ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -p ${TARGET_PORT} ${TUNNEL_DEF} ${TARGET} # Restart every >2 seconds to avoid StartLimitInterval failure RestartSec=5 Restart=always [Install] WantedBy=default.target