Files
kaskad-pro/_ssh_debug.py
2026-03-07 15:08:58 +03:00

24 lines
744 B
Python

import paramiko, sys
host = "185.250.47.205"
user = "root"
pwd = "0i1sbf9NM36FkG5dFH"
def run(cmd, timeout=30):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=user, password=pwd, timeout=10)
stdin, stdout, stderr = ssh.exec_command(cmd, timeout=timeout)
out = stdout.read().decode(errors="replace")
err = stderr.read().decode(errors="replace")
rc = stdout.channel.recv_exit_status()
ssh.close()
return rc, out, err
if __name__ == "__main__":
cmd = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "echo ok"
rc, out, err = run(cmd)
if out: print(out, end="")
if err: print("STDERR:", err, end="")
print(f"\n[exit {rc}]")