summaryrefslogtreecommitdiff
path: root/port-forward/persistent-ssh.sh
diff options
context:
space:
mode:
Diffstat (limited to 'port-forward/persistent-ssh.sh')
-rwxr-xr-xport-forward/persistent-ssh.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/port-forward/persistent-ssh.sh b/port-forward/persistent-ssh.sh
new file mode 100755
index 0000000..086bfc6
--- /dev/null
+++ b/port-forward/persistent-ssh.sh
@@ -0,0 +1,27 @@
1#!/bin/bash
2
3sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service
4[Unit]
5Description=Persistent SSH Tunnel
6After=network.target
7StartLimitIntervalSec=0
8
9[Service]
10Type=simple
11ExecStart=/usr/bin/ssh \
12 -i /root/m \
13 -o "ExitOnForwardFailure=yes" \
14 -o "StrictHostKeyChecking=no" \
15 -N -R 24:localhost:22 root@p.0nom.ch
16Restart=always
17RestartSec=10
18RemainAfterExit=no
19KillMode=process
20
21[Install]
22WantedBy=multi-user.target
23EOF
24
25sudo chmod 600 /root/m
26sudo systemctl daemon-reload
27sudo systemctl enable --now ssh-tunnel