30 lines
825 B
Python
30 lines
825 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
key_path = r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet'
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.71", username="root", key_filename=key_path, timeout=10)
|
|
|
|
def run(cmd):
|
|
stdin, stdout, stderr = c.exec_command(cmd)
|
|
return stdout.read().decode('utf-8', errors='ignore').strip()
|
|
|
|
print("1. Creating temporary eth0.50 on 140.44.4.71...")
|
|
run("ip link add link eth0 name eth0.50 type vlan id 50")
|
|
run("ip addr add 14.4.4.99/25 dev eth0.50")
|
|
run("ip link set eth0.50 up")
|
|
|
|
print("2. Pinging gateway 14.4.4.1 from eth0.50:")
|
|
ping_out = run("ping -c 2 -I eth0.50 14.4.4.1")
|
|
print(ping_out)
|
|
|
|
print("3. Cleaning up temporary interface...")
|
|
run("ip link del eth0.50")
|
|
print("Cleaned up.")
|
|
|
|
c.close()
|
|
|