27 lines
974 B
Python
27 lines
974 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('140.44.4.71', username='snarf', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
def run(cmd):
|
|
_, o, _ = c.exec_command(cmd)
|
|
return o.read().decode().strip()
|
|
|
|
print("Testing https://portal.snarfnet.net:")
|
|
status_portal = run("curl -sk -o /dev/null -w '%{http_code}' https://portal.snarfnet.net")
|
|
print(" Status code:", status_portal)
|
|
title_portal = run("curl -sk https://portal.snarfnet.net | grep -i '<title>'")
|
|
print(" Title:", title_portal)
|
|
|
|
print("\nTesting https://heimdall.snarfnet.net:")
|
|
status_heimdall = run("curl -sk -o /dev/null -w '%{http_code}' https://heimdall.snarfnet.net")
|
|
redirect_heimdall = run("curl -sk -I https://heimdall.snarfnet.net | grep -i 'location'")
|
|
print(" Status code:", status_heimdall)
|
|
print(" Redirect location:", redirect_heimdall)
|
|
|
|
c.close()
|
|
|