diff options
| author | hc <hc@email.ch> | 2024-11-23 17:35:46 +0800 |
|---|---|---|
| committer | hc <hc@email.ch> | 2024-11-23 17:35:46 +0800 |
| commit | ba9539a4f49d722063e5a322133c89affd6a9fb7 (patch) | |
| tree | 5f72a881ad2affbf03186976b59c6df1ffb1d51f | |
| parent | ab5d9a6966b6b8fdd6ce9821b86ab0f3b74cc6a5 (diff) | |
persistentssh
| -rw-r--r-- | others/.vm.sh2.swp | bin | 16384 -> 0 bytes | |||
| -rwxr-xr-x | port-forward/persistent-ssh.sh | 27 |
2 files changed, 27 insertions, 0 deletions
diff --git a/others/.vm.sh2.swp b/others/.vm.sh2.swp deleted file mode 100644 index e075ed6..0000000 --- a/others/.vm.sh2.swp +++ /dev/null | |||
| Binary files differ | |||
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 | |||
| 3 | sudo cat << 'EOF' > /etc/systemd/system/ssh-tunnel.service | ||
| 4 | [Unit] | ||
| 5 | Description=Persistent SSH Tunnel | ||
| 6 | After=network.target | ||
| 7 | StartLimitIntervalSec=0 | ||
| 8 | |||
| 9 | [Service] | ||
| 10 | Type=simple | ||
| 11 | ExecStart=/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 | ||
| 16 | Restart=always | ||
| 17 | RestartSec=10 | ||
| 18 | RemainAfterExit=no | ||
| 19 | KillMode=process | ||
| 20 | |||
| 21 | [Install] | ||
| 22 | WantedBy=multi-user.target | ||
| 23 | EOF | ||
| 24 | |||
| 25 | sudo chmod 600 /root/m | ||
| 26 | sudo systemctl daemon-reload | ||
| 27 | sudo systemctl enable --now ssh-tunnel | ||
