Day 27 - Getting Hands-On with Python & Network

This commit is contained in:
Michael Cade
2022-01-27 15:22:36 +00:00
parent 1677511e6e
commit 8ca6594031
28 changed files with 1293 additions and 6 deletions

View File

@ -0,0 +1,22 @@
#!/usr/bin/python
import paramiko
import time
Channel = paramiko.SSHClient()
Channel.set_missing_host_key_policy(paramiko.AutoAddPolicy())
Channel.connect(hostname="192.168.169.115", username='admin', password='access123', look_for_keys=False, allow_agent=False)
shell = Channel.invoke_shell() # This will set interactive shell
shell.send("enable\n")
shell.send("access123\n")
shell.send("terminal length 0\n")
shell.send("show ip int b\n")
shell.send("show arp \n")
time.sleep(2)
print(shell.recv(5000))
# This will receive everything from the buffer, if you need to receive specifc output, the you should execute the command
# and immediately receive the output before executing the 2nd command, Also you should sleep a little
Channel.close()