17 lines
908 B
Python
17 lines
908 B
Python
|
|
import os, sys, paramiko
|
||
|
|
PW = os.environ.get("REMOTE_PASS", "")
|
||
|
|
c = paramiko.SSHClient()
|
||
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||
|
|
c.connect("207.57.129.228", port=19717, username="root", password=PW, timeout=15, allow_agent=False, look_for_keys=False)
|
||
|
|
def run(cmd):
|
||
|
|
si, so, se = c.exec_command(cmd, timeout=15)
|
||
|
|
out = so.read().decode("utf-8", "replace")
|
||
|
|
err = se.read().decode("utf-8", "replace")
|
||
|
|
print(f"$ {cmd}")
|
||
|
|
if out: print(out, end="")
|
||
|
|
if err: print("[err]", err, end="", file=sys.stderr)
|
||
|
|
run("ls -la /root/.ssh/ && echo --- && cat /root/.ssh/authorized_keys | head -1 | cut -c1-100")
|
||
|
|
run("sshd -T 2>/dev/null | grep -iE 'pubkeyauth|permitroot|authentic' | head -20")
|
||
|
|
run("grep -E 'PubkeyAuthentication|PermitRootLogin|PasswordAuthentication|AuthorizedKeysFile' /etc/ssh/sshd_config 2>/dev/null; echo --- && ls -la /etc/ssh/sshd_config.d/ 2>/dev/null")
|
||
|
|
c.close()
|