# -*- coding: utf-8 -*- from __future__ import annotations import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") CMD = r""" ps -eo pid,ppid,lstart,cmd | grep '[f]fmpeg' | grep rtmps.youtube echo '---' ps -eo pid,cmd | grep -E '[u]vicorn|[d]ouyinweb' | head -20 echo '---' # show stream keys in both cmds python3 - <<'PY' import subprocess for line in subprocess.getoutput('ps -eo pid,cmd').splitlines(): if 'ffmpeg' in line and 'rtmps.youtube' in line: print(line.strip()[:300]) if 'live2/' in line: i=line.find('live2/') print('KEY', line[i:i+40]) PY """ c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False) _, o, e = c.exec_command(CMD, timeout=30) print(o.read().decode("utf-8", "replace")) print(e.read().decode("utf-8", "replace")[-500:]) c.close()