#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") SH = r""" echo "===== regular neko cookie auth check =====" for i in 1 2 3; do python3 - </dev/null stat /opt/douyinWEB/backend/data/ops_neko/profiles/*/Default/Cookies | grep -E 'File:|Modify|Size' echo "===== ops hub / assign pairing still in DB? =====" python3 - <<'PY' import sqlite3 from pathlib import Path for db in [ Path('/opt/douyinWEB/backend/data/monitor.db'), Path('/opt/douyinWEB/backend/data/ops_neko.db'), ]: if not db.exists(): print('missing', db); continue print('DB', db, db.stat().st_size) con=sqlite3.connect(f'file:{db}?mode=ro', uri=True) cur=con.cursor() cur.execute("select name from sqlite_master where type='table' order by 1") tables=[r[0] for r in cur.fetchall()] print(' tables', tables[:40]) for t in tables: if any(x in t.lower() for x in ('ops','neko','hub','cred','pair','assign','studio')): try: cur.execute(f'select count(*) from {t}') print(f' {t}:', cur.fetchone()[0]) except Exception as e: print(' err', t, e) con.close() PY """ def main() -> None: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False) sftp = c.open_sftp() with sftp.file("/tmp/_check_login_left.sh", "wb") as f: f.write(SH.encode()) sftp.close() _i, o, e = c.exec_command("echo 4669805 | sudo -S -p '' bash /tmp/_check_login_left.sh", timeout=90) print((o.read() + e.read()).decode("utf-8", "replace")) c.close() if __name__ == "__main__": main()