Skip to content

Instantly share code, notes, and snippets.

@corny
Created November 17, 2016 10:11
Show Gist options
  • Save corny/75e14c948fa7f2cb6c63da07fba3fb85 to your computer and use it in GitHub Desktop.
Save corny/75e14c948fa7f2cb6c63da07fba3fb85 to your computer and use it in GitHub Desktop.
KTI switch ARP table
#!/usr/bin/env python3
# Script to read the ARP table from a KTI switch using SSH without password
import pexpect
import sys
from collections import defaultdict
res = defaultdict(list)
prompt = '\S+:/>'
s = pexpect.spawn("sshpass", ["-p",'', "ssh", "-l", "admin", "-oStrictHostKeyChecking=no", "-oKexAlgorithms=+diffie-hellman-group1-sha1", sys.argv[1]])
s.expect(prompt)
s.send("mac dump\r\n")
s.expect("\r\n")
s.expect(prompt)
print(s.before.decode('utf-8'))
s.sendline('logout\r')
s.sendeof()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment