summaryrefslogtreecommitdiff
path: root/.config/systemd/user/secure-tunnel@.service
blob: f97f3bac17acf26b5376faf40db69be57c6a00ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[Unit]
Description=Setup a secure tunnel to %I
After=network.target

#
# Add secure-tunnel@<name> 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