30 lines
992 B
Python
30 lines
992 B
Python
import paramiko
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
try:
|
|
ssh.connect('140.44.4.21', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
print("SSH connection to 140.44.4.21 SUCCESSFUL!")
|
|
|
|
cmds = [
|
|
"uptime",
|
|
"df -h /",
|
|
"ps aux | grep -i dietpi",
|
|
"ls -la /boot/Automation_Custom_Script.sh",
|
|
"ls -la /var/tmp/dietpi/logs/",
|
|
"cat /var/tmp/dietpi/logs/dietpi-firstrun-setup.log 2>/dev/null | tail -n 20",
|
|
"systemctl status k3s-agent --no-pager 2>&1",
|
|
"systemctl status zabbix-agent2 --no-pager 2>&1"
|
|
]
|
|
for cmd in cmds:
|
|
print(f"\n--- {cmd} ---")
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
out = stdout.read().decode().strip()
|
|
err = stderr.read().decode().strip()
|
|
if out: print(out)
|
|
if err: print("[ERR]", err)
|
|
ssh.close()
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|