-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasa-fw01_ShowVersion.py
38 lines (33 loc) · 991 Bytes
/
asa-fw01_ShowVersion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin python3
"""
Use Paramiko to retrieve the entire 'show version' output from pynet-rtr2.
"""
import time
from getpass import getpass
import paramiko
IP_ADDRESS = '192.168.1.59'
USERNAME = 'befthimi'
PASSWORD = getpass()
PORT = 22
def get_showver(connection):
"""
Get the show version output and display on screen
with no terminal paging
"""
connection.settimeout(5.0)
# connection.send("terminal pager 0\n")
data_buffer = connection.send("show version\n")
time.sleep(2)
data_buffer = connection.recv(5000)
print (data_buffer)
def main():
"""
The main function
"""
remote_conn_pre = paramiko.SSHClient()
remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
remote_conn_pre.connect(IP_ADDRESS, username=USERNAME, password=PASSWORD, look_for_keys=False, allow_agent=False, port=PORT)
remote_conn = remote_conn_pre.invoke_shell()
get_showver(remote_conn)
if __name__ == "__main__":
main()