-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparamiko-nokia.py
More file actions
executable file
·40 lines (34 loc) · 1.01 KB
/
paramiko-nokia.py
File metadata and controls
executable file
·40 lines (34 loc) · 1.01 KB
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
38
39
40
#!/usr/bin/python
import paramiko
import sys
import getpass
import time
myusername = str(raw_input("Please input your username: "))
mypassword = getpass.getpass()
print myusername
if len(sys.argv) > 1:
connect_to = sys.argv[1]
else:
print "Please supply a host to connect to"
exit()
def remote_connect(hostname, conf):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname, username=myusername, password=mypassword, look_for_keys=False)
print "Connected to %s" % hostname
chan = ssh.invoke_shell()
chan.send("\n\nenvironment no more\n\n")
time.sleep(1)
chan.send(conf)
time.sleep(2)
chan.send("logout\n")
print chan.recv(100000)
ssh.close()
except paramiko.SSHException as error:
print "%s gave error %s" % hostname, error
sys.exit(1)
cmd = "admin display-config\n\n"
remote_connect(connect_to, cmd)
cmd = "show bof\n\n"
remote_connect(connect_to, cmd)