diff options
Diffstat (limited to 'port-forward/persistent-ssh.sh')
| -rwxr-xr-x | port-forward/persistent-ssh.sh | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/port-forward/persistent-ssh.sh b/port-forward/persistent-ssh.sh deleted file mode 100755 index 36d14dd..0000000 --- a/port-forward/persistent-ssh.sh +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | echo "selinux command is untested. copy paste systemd file if you want" | ||
| 4 | echo "reboot afterwards(selinux unset, need reboot to take effect, or just do sudo setenforce 0 for temp unset)" | ||
| 5 | echo "make sure /root/m exists" | ||
| 6 | echo "remember to change the remote port or host if needed" | ||
| 7 | |||
| 8 | # disable selinux | ||
| 9 | sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config | ||
| 10 | |||
| 11 | sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service | ||
| 12 | [Unit] | ||
| 13 | Description=Persistent SSH Tunnel | ||
| 14 | After=network.target | ||
| 15 | StartLimitIntervalSec=0 | ||
| 16 | |||
| 17 | [Service] | ||
| 18 | Type=simple | ||
| 19 | ExecStart=/usr/bin/ssh \ | ||
| 20 | -i /root/m \ | ||
| 21 | -o "ExitOnForwardFailure=yes" \ | ||
| 22 | -o "StrictHostKeyChecking=no" \ | ||
| 23 | -N -R 24:localhost:22 root@p.0nom.ch | ||
| 24 | Restart=always | ||
| 25 | RestartSec=10 | ||
| 26 | RemainAfterExit=no | ||
| 27 | KillMode=process | ||
| 28 | |||
| 29 | [Install] | ||
| 30 | WantedBy=multi-user.target | ||
| 31 | EOF | ||
| 32 | |||
| 33 | sudo chmod 600 /root/m | ||
| 34 | sudo systemctl daemon-reload | ||
| 35 | sudo systemctl enable --now ssh-tunnel | ||
