py-junos-eznc icon indicating copy to clipboard operation
py-junos-eznc copied to clipboard

Getting wrong username/password error while connecting through serial mode

Open Aaron-MJohn opened this issue 3 years ago • 4 comments

I am able to connect to a switch with no password through serial mode without any error. But after setting password to the switch when I try to connect through serial mode I have seen the code fail randomly. Some times I am able to connect but most of the time I get ConnectAuthError(host: None, msg: Bad username/password).

When I looked at the code I see the serial read output shows the password was provided for the login prompt after 1st password fail.


2023-02-02 14:40:15,136 - [tty.py:107] - [INFO]: TTY: connecting to TTY:COM3 ..."
2023-02-02 14:40:15,139 - [tty.py:110] - [INFO]: TTY: logging in......"
2023-02-02 14:40:15,255 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:15,364 - [tty_serial.py:86] - [INFO]: output: b'\r\n'"
2023-02-02 14:40:15,474 - [tty_serial.py:86] - [INFO]: output: b'\r\n'"
2023-02-02 14:40:15,583 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:15,692 - [tty_serial.py:86] - [INFO]: output: b'FreeBSD/arm (sw0) (ttyu0)\r\r\n'"
2023-02-02 14:40:15,803 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:15,904 - [tty_serial.py:86] - [INFO]: output: b'log \r\n'"
2023-02-02 14:40:16,014 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:16,123 - [tty_serial.py:86] - [INFO]: output: b'FreeBSD/arm (sw0) (ttyu0)\r\r\n'"
2023-02-02 14:40:16,232 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:16,343 - [tty_serial.py:86] - [INFO]: output: b'login: \r\r\r\n'"
2023-02-02 14:40:16,452 - [tty_serial.py:86] - [INFO]: output: b'FreeBSD/arm (yu0)\r\r\n'"
2023-02-02 14:40:16,561 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:16,671 - [tty_serial.py:86] - [INFO]: output: b'login: \r\n'"
2023-02-02 14:40:16,780 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:16,890 - [tty_serial.py:86] - [INFO]: output: b'FreeBSD/arm (sw0) (ttyu0)\r\r\n'"
2023-02-02 14:40:17,005 - [tty_serial.py:86] - [INFO]: output: b'\r\r\n'"
2023-02-02 14:40:17,114 - [tty_serial.py:86] - [INFO]: output: b'login: root\r\n'"
2023-02-02 14:40:17,223 - [tty_serial.py:86] - [INFO]: output: b'Password:\r\n'"
2023-02-02 14:40:17,326 - [tty_serial.py:86] - [INFO]: output: b'Login incorrect\r\n'"
2023-02-02 14:40:17,444 - [tty_serial.py:86] - [INFO]: output: b'login: password_string\r\n'"
2023-02-02 14:40:17,546 - [tty_serial.py:86] - [INFO]: output: b'Password:\r\n'"
2023-02-02 14:40:17,660 - [tty_serial.py:86] - [INFO]: output: b'\r\n'"
2023-02-02 14:40:17,771 - [tty_serial.py:86] - [INFO]: output: b'password_string\r\n'"
2023-02-02 14:40:17,879 - [tty_serial.py:86] - [INFO]: output: b'Login incorrect\r\n'"
2023-02-02 14:40:17,879 - [console.py:215] - [ERROR]: Exception occurred: login:ConnectAuthError(host: None, msg: Bad username/password)
"
2023-02-02 14:40:17,880 - - [ERROR]: Failed to Authenticate username and password: ConnectAuthError(host: None, msg: Bad username/password)"
2023-02-02 14:40:17,880 - - [ERROR]: Wrong username or password"

output is from this https://github.com/Juniper/py-junos-eznc/blob/79d560d1d3ab922d1668a4f976e5c4e895dde795/lib/jnpr/junos/transport/tty_serial.py#L84

Aaron-MJohn avatar Feb 02 '23 20:02 Aaron-MJohn

I tried to increase the sleep time before reading the output. But still having issue.

Aaron-MJohn avatar Feb 02 '23 20:02 Aaron-MJohn

I see after first bad password, the code enter's password for login instead of username. Which cause login incorrect error.

Aaron-MJohn avatar Feb 02 '23 20:02 Aaron-MJohn

Which box is this tried on? What is the Junos s/w version?

ydnath avatar Feb 03 '23 04:02 ydnath

This is from EX-2300-C JUNOS 20.4R3-S3.4.

Aaron-MJohn avatar Feb 03 '23 14:02 Aaron-MJohn