1. [Unit]
  2. Description=Keeps a tunnel to 'remote.example.com' open
  3. After=network.target
  4. [Timer]
  5. #This portion doesnt work
  6. OnBootSec=4min
  7. [Service]
  8. User=root
  9. Type=forking
  10. # -p [PORT]
  11. # -l [user]
  12. # -M 0 --> no monitoring
  13. # -N Just open the connection and do nothing (not interactive)
  14. # LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
  15. #Environment="LOCAL_ADDR=localhost"
  16. #EnvironmentFile=/etc/default/secure-tunnel@%i
  17. Environment="AUTOSSH_GATETIME=0"
  18. ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -D3130 -p 6000 USER@HOSTNAME -i /root/.ssh/id_rsa 2>&1
  19. #ExecStart=/usr/bin/autossh -M 0 -N -T -q -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -D3130 -p 6000 USER@HOSTNAME -i /root/.ssh/id_rsa
  20. ExecStop=/usr/bin/kill $(lsof -t -i:3130)
  21. #RestartSec=400
  22. #Restart=always
  23. [Install]
  24. WantedBy=multi-user.target