[systemd-devel] Setting Up SSH Tunnels
h.reindl at thelounge.net
Fri Jul 5 12:04:29 PDT 2013
Am 05.07.2013 19:16, schrieb CACook at Quantum-Sci.com:
> 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
> Description= reverse SSH tunnels
> After=network.target sockets.target syslog.target
> # Do a single job and then exit (Can have multiple ExecStarts):
> # For oneshot, so that systemd still considers the service as active after the process has exited:
> ExecStop=/bin/kill -15 $MAINPID
> # Errors in /var/log/messages
"oneshot" is plain wrong if you have a long living prcoess
below a working unit to have a remote-server's ssh on localhost:10024
"RestartSec=60" because so it survives reboots of the forwarded machine with auto reconnect
ExecStart=/usr/bin/ssh -i /home/gateway/.ssh/id_rsa gateway at target-host -N -C -L127.0.0.1:10024:127.0.0.1:22
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 263 bytes
Desc: OpenPGP digital signature
More information about the systemd-devel