I am getting this error when trying to run a script that edits the junos config:
Traceback (most recent call last):
File "edit-config.py", line 26, in <module>
switch.open()
File "/usr/lib/python2.7/site-packages/jnpr/junos/device.py", line 880, in open
raise EzErrors.ConnectAuthError(self)
jnpr.junos.exception.ConnectAuthError: ConnectAuthError([SWITCH-NAME])
I know this error indicates that the username or password is incorrect. However, I have tried hardcoding known good credentials into the script and get the same error. I am able to ssh to the switch manually with these credentials outside of the script. Code pasted below. I've taken out any potentially identifiable info for privacy. I'd also like to note that I enabled netconf on the switch with 'set system services netconf ssh'. Any help would be greatly appreciated.
#!/usr/bin/python
2
3 """edit-config.py: makes changes to the Junos config."""
4
5 from jnpr.junos import Device
6 from jnpr.junos.utils.config import Config
7 import sys
8
9 # promt user for login info
10 hostname = raw_input("Hostname: ")
11 user = raw_input("User: ")
12 password = raw_input("Password: ")
13
14 # create a device object from login info above
15 switch = Device(hostname, user, password)
16
17 # open a connection to the device object
18 # throw an error if unsuccessful
19 """
20 try:
21 switch.open()
22 except Exception as err:
23 print("Unable to connect to " + hostname + ".")
24 sys.exit(1)
25 """
26 switch.open()
27
28 # get the config and lock it so no one else can make changes
29 cfg = Config(switch)
30 cfg.lock()
31
32 # append to config
33 # in this case, adding an IP to firewall filter [FILTER-NAME]
34 cfg.load("set firewall family inet filter [FILTER-NAME] term 2-1 from source-address [IP-ADDRESS]", format="set", merge=True)
35
36 # unlock config
37 cfg.unlock()
38
39 # close connection to device
40 switch.close()