mirror of
https://github.com/MichaelCade/90DaysOfDevOps.git
synced 2025-07-13 09:20:09 +07:00
Day 27 - Getting Hands-On with Python & Network
This commit is contained in:
22
Days/Networking/paramiko_show.py
Normal file
22
Days/Networking/paramiko_show.py
Normal 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()
|
Reference in New Issue
Block a user