Skip to content

Instantly share code, notes, and snippets.

@edi33416
Created November 29, 2018 15:03
Show Gist options
  • Save edi33416/050af17852752122dc1994b2494cd525 to your computer and use it in GitHub Desktop.
Save edi33416/050af17852752122dc1994b2494cd525 to your computer and use it in GitHub Desktop.
systemd service script to create a reverse tunnel; Kudos Sergiu W (@Sergiu121)
[Unit]
Description=Keeps a tunnel to 'fep.grid.pub.ro' open
After=network-online.target ssh.service
[Service]
User=<user-name>
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
# LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
Environment=AUTOSSH_GATETIME=0
ExecStart=/usr/bin/autossh -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R <remote-port>:localhost:22 <user-name>@<remote-machine>
#ExecReload=/usr/bin/pkill --signal SIGKILL -f '/usr/lib/autossh.+fep.+'
#ExecStop=/usr/bin/pkill --signal SIGKILL -f '/usr/lib/autossh.+fep.+'
KillMode=process
Restart=on-failure
RestartSec=10
Type=forking
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment