For some years I've set up reverse SSH tunnels with a script, but when the tunnels go down they do not recover. I'd like to start and stop the tunnels using systemd.

A typical command looks like this:
/usr/bin/ssh -f -l sleeper -i /home/sleeper/.ssh/id_ecdsa -2 -4 -c aes256-ctr,aes128-ctr -L 3128:localhost:3128 droog sleep 365d

I tried invoking my script with a .service file, but it doesn't keep the tunnels alive. (sometimes they die with "broken pipe") And it doesn't re-establish the tunnels on wake from sleep.

This is my .service file:
# sshdroog.service

[Unit]
Description= reverse SSH tunnels
Before=rc.local.service
After=network.target sockets.target syslog.target

[Service]
# Do a single job and then exit (Can have multiple ExecStarts):
Type=oneshot
# For oneshot, so that systemd still considers the service as active after the process has exited:
RemainAfterExit=yes
ExecStart=/usr/local/bin/sshcygnus
ExecStop=/bin/kill -15 $MAINPID
Restart=always
RestartSec=2
TimeoutSec=60
# Errors in /var/log/messages
systemd.log_level=debug
#Type=notify
#StandardError=syslog
#NotifyAccess=main

[Install]
WantedBy=multi-user.target


_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to