34 lines
954 B
Python
34 lines
954 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('14.4.4.44', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
def run(cmd):
|
|
stdin, stdout, stderr = c.exec_command(cmd)
|
|
return stdout.read().decode().strip(), stderr.read().decode().strip()
|
|
|
|
print("--- ping 14.4.4.20 from nutserver ---")
|
|
out, _ = run("ping -c 2 14.4.4.20")
|
|
print(out)
|
|
|
|
print("--- ping 14.44.4.108 from nutserver ---")
|
|
out, _ = run("ping -c 2 14.44.4.108")
|
|
print(out)
|
|
|
|
print("--- traceroute 140.44.4.74 from nutserver ---")
|
|
out, _ = run("traceroute -n -m 5 140.44.4.74 || tracepath -n 140.44.4.74")
|
|
print(out)
|
|
|
|
print("--- ufw / iptables on nutserver ---")
|
|
out, _ = run("echo 'Katzir476!' | sudo -S ufw status verbose")
|
|
print("UFW:", out)
|
|
|
|
out, _ = run("echo 'Katzir476!' | sudo -S nft list ruleset")
|
|
print("NFT:", out)
|
|
|
|
c.close()
|
|
|