29 lines
654 B
Python
29 lines
654 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
KEY_FILE = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet'
|
|
IP = '14.4.4.44'
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect(IP, username='snarf', key_filename=KEY_FILE, timeout=10)
|
|
|
|
def run(cmd):
|
|
print(f"\n>>> {cmd}")
|
|
_, o, e = ssh.exec_command(cmd)
|
|
out = o.read().decode().strip()
|
|
if out:
|
|
print(out)
|
|
return out
|
|
|
|
run("uptime")
|
|
run("cat /etc/nut/nut.conf")
|
|
run("cat /etc/nut/ups.conf")
|
|
run("cat /etc/nut/upsmon.conf | grep -v '^#' | grep -v '^$'")
|
|
run("ps aux | grep -i nut")
|
|
run("ls -la /run/nut")
|
|
|
|
ssh.close()
|
|
|