SSH Tunnel
[Unit]
Description=Setup a secure tunnel to Fi-Dev server
After=network.target
[Service]
Type=simple
User=tunnel
Group=tunnel
EnvironmentFile=/etc/default/secure-tunnel@aws
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR ${REMOTE_PORT}:${LOCAL_ADDR}:${LOCAL_PORT} -p ${SSH_TARGET_PORT} ${USERNAME}@${TARGET} -i /home/tunnel/.ssh/id_rsa
# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
/etc/default/secure-tunnel
TARGET={remote server IP}
LOCAL_ADDR=0.0.0.0
LOCAL_PORT=22
REMOTE_PORT=8023
USERNAME=tunnel
SSH_TARGET_PORT=22