autossh-tunnel.service/autossh-tunnel.service

12 lines
553 B
SYSTEMD

[Unit]
Description=autossh tunnel
After=network-online.target
[Service]
User=<user> # Make sure user has access to the relevant ssh key
ExecStart=/usr/bin/autossh -C -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" <-L, -R or -D port forward> -M 2000 <user>@<host> -i /home/<user>/.ssh/<ssh_key>
# Add "GatewayPorts yes" to the server's sshd_config if you want external access to remote ssh port forwards
# Example port forward remotley accessing a computer behind a NAT/firewall: -R 2222:127.0.0.1:22
[Install]
WantedBy=multi-user.target