nomadro/apps/miniprogram/weapp/scripts/_ssh_probe_hackrobot.py
eric 3e5b7c2098 Monorepo super-optimize: src layout, workspace scripts, docs.
Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-01 00:34:04 +08:00

49 lines
1.5 KiB
Python

import paramiko
import sys
from pathlib import Path
host = "129.204.21.129"
user = "ubuntu"
password = "Xiao4669805"
out_path = Path(__file__).with_name("_ssh_probe_hackrobot.out.txt")
cmd = r"""
set +e
echo "=== whoami ==="; whoami; hostname
echo "=== find book/ebook/hackrobot dirs ==="
for d in /var/www /home /opt /srv /data /www /root /mnt; do
[ -d "$d" ] || continue
echo "-- $d --"
find "$d" -maxdepth 5 \( -iname '*book*' -o -iname '*ebook*' -o -iname '*nomad*' -o -iname '*hackrobot*' -o -iname '*dgnomad*' \) 2>/dev/null | head -120
done
echo "=== nginx/caddy ==="
ls /etc/nginx/sites-enabled 2>/dev/null
ls /etc/caddy 2>/dev/null
grep -Rsn "hackrobot" /etc/nginx /etc/caddy 2>/dev/null | head -60
echo "=== md files ==="
find /var/www /home /opt /srv /data /www -name '*.md' 2>/dev/null | head -100
echo "=== docker/pm2 ==="
docker ps --format '{{.Names}} {{.Image}} {{.Ports}}' 2>/dev/null | head -40
pm2 list 2>/dev/null | head -50
echo "=== home ==="
ls -la /home/ubuntu 2>/dev/null | head -60
"""
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(
host,
username=user,
password=password,
timeout=25,
allow_agent=False,
look_for_keys=False,
)
_stdin, stdout, stderr = client.exec_command(cmd, timeout=180)
out = stdout.read().decode("utf-8", errors="replace")
err = stderr.read().decode("utf-8", errors="replace")
client.close()
out_path.write_text(out + ("\nSTDERR:\n" + err if err.strip() else ""), encoding="utf-8")
print(f"wrote {out_path} bytes={out_path.stat().st_size}")