From f165be75f782029ca91ad023267a89900b86d9df Mon Sep 17 00:00:00 2001 From: Mehdi Sadeghi Date: Sun, 25 Apr 2021 19:05:29 +0200 Subject: Add ssh-tunnel template. --- .config/systemd/user/secure-tunnel@.service | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .config/systemd/user/secure-tunnel@.service (limited to '.config/systemd/user') diff --git a/.config/systemd/user/secure-tunnel@.service b/.config/systemd/user/secure-tunnel@.service new file mode 100644 index 0000000..f97f3ba --- /dev/null +++ b/.config/systemd/user/secure-tunnel@.service @@ -0,0 +1,23 @@ +[Unit] +Description=Setup a secure tunnel to %I +After=network.target + +# +# Add secure-tunnel@ file with necessary env vars: +# +#USER= # user to run the unit with +#REMOTE_PORT= # some port on the remote machine to forward to +#REMOTE_USER= # user on the remote machine +#TARGET_PORT= # ssh port of the target machine usually 22 +# +[Service] +User="${USER}" +EnvironmentFile=%h/.config/systemd/user/secure-tunnel@%i +ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R ${REMOTE_PORT}:localhost:${TARGET_PORT} ${TARGET} -l ${REMOTE_USER} + +# Restart every >2 seconds to avoid StartLimitInterval failure +RestartSec=5 +Restart=always + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3