#!/usr/bin/env python3 import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "107.173.30.245", 4014, "eric", "4669805", timeout=40, banner_timeout=80, allow_agent=False, look_for_keys=False, ) cmd = r"""echo '4669805' | sudo -S -p '' bash -lc ' git config --global --add safe.directory /opt/douyinWEB 2>/dev/null || true cd /opt/douyinWEB && git log -1 --oneline curl -sS -m 10 --noproxy "*" http://127.0.0.1:8014/api/health | head -c 200; echo curl -sS -m 10 --noproxy "*" http://127.0.0.1:8014/api/ops/host-profile | head -c 400; echo systemctl is-active douyinweb-api douyinweb-web ' """ _i, o, e = c.exec_command(cmd, timeout=60) print((o.read() + e.read()).decode("utf-8", "replace")) c.close()