# -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") REMOTE = """ cd /opt/douyinWEB/backend .venv/bin/python - <<'PY' from app import db rows = db.list_shorts_channels(enabled=None) print("channels_total", len(rows)) for r in rows: print(r.get("oauth_profile_id"), r.get("name"), "enabled", r.get("enabled")) PY """ c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False) _i, o, e = c.exec_command(REMOTE, timeout=60) print(o.read().decode("utf-8", "replace")) c.close()