Bruno Ferreira
unread,Mar 28, 2022, 7:12:12 AM3/28/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Junos Python EZ
Hi,
I have successfully used jnpr.junos.device to connect directly via SSH to Juniper network devices and also to connect to the same devices via console servers, when using telnet connection.
However, I'm struggling to get it to work with console servers that use SSH connection.
The console servers (which are two different devices, one is configured to be accessed via telnet (this one works fine) and the other is configured to be accessed via SSH (this one I can't connect to)) are both Avocent 6000 Series (same model).
Via command prompt, I can connect successfully to switch1, which is connected to the SSH console server on port 7012, like this:
terminal_server -> ssh cs_usr:cs_port@cs_hostname
IF YOU ARE NOT AN AUTHORIZED USER, PLEASE EXIT IMMEDIATELY
Password:
Type the hot key to suspend the connection: <CTRL>Z
FreeBSD/amd64 (switch1) (ttyu0)
login: junos_username
Password:
--- JUNOS 18.4R3-S7.2 Kernel 64-bit FLEX JNPR-11.0-20201221.5316c2e_buil
{master:0}
junos_username@switch1> exit
FreeBSD/amd64 (switch1) (ttyu0)
login:
--:- 26-35-cc-p-12 cli-> exit
The code I'm using to attempt the same via script is this:
cs_hostname = 'cs_hostname'
cs_port = '7012'
cs_usr = 'cs_usr'
cs_pwd = 'cs_pwd'
junos_username = 'junos_username'
junos_password = 'junos_password'
try:
with Device(host=cs_hostname, user=junos_username, passwd=junos_password, cs_user=(cs_usr + ':' + cs_port), cs_passwd=cs_pwd, console_has_banner=True, gather_facts=True) as dev:
device_sn = dev.facts['serialnumber']
print(device_sn)
except Exception as e:
print(e)
When I run it, I get the following error:
terminal_server -> python my_script.py
ERROR:jnpr.junos.console:Exception occurred: login:'lxml.etree._Element' object has no attribute 'decode'
'lxml.etree._Element' object has no attribute 'decode'
terminal_server ->
Any help to find out why I get this error and can't connect would be much appreciated.
Thanks in advance.
Bruno Ferreira