Repository: ktbyers/netmiko

Issue:
Huawei special_login_handler is not logging in successfully
The system information is as follows:
1. netmiko version: 4.0
2. python 3.10
3. window 11

error_print:
```shell
Traceback (most recent call last):
  File "E:\web_API\test.py", line 11, in <module>
    app.net_ssh_proxy(switch_json = switch_json, commands=commands)
  File "E:\web_API\app.py", line 25, in net_ssh_proxy
    with ConnectHandler(**device_info, sock=sock) as net_connect:
  File "E:\venv_02\lib\site-packages\netmiko\ssh_dispatcher.py", line 344, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 434, in __init__
    self._open()
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 439, in _open
    self.establish_connection()
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 1092, in establish_connection
    self.special_login_handler()
  File "E:\venv_02\lib\site-packages\netmiko\huawei\huawei.py", line 105, in special_login_handler
    output = self.read_until_pattern(password_change_prompt)
  File "E:\venv_02\lib\site-packages\netmiko\base_connection.py", line 631, in read_until_pattern
    raise ReadException(msg)
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=((Change now|Please choose))|([\]>]\s*$)
output='\nInfo: The max number of VTY users is 21, the number of current VTY users online is 2, and total number of terminal users online is 2.\n      The current login time is 2022-03-28 15:55:30+08:00.\n<xxxx_hostname>'
results=['\nInfo: The max number of VTY users is 21, the number of current VTY users online is 2, and total number of terminal users online is 2.\n      The current login time is 2022-03-28 15:55:30+08:00.\n<xxxx_hostname', None, None, '>', '']

```


test instanse
2. python 3.10
3. window 11
[Netmiko 3.4.0 Release](https://github.com/ktbyers/netmiko/releases/tag/v3.4.0)

out_print

no problem



Discussion:
are you trying to do it with Huawei device_type?

Cause I have the same problem.
Tes instance
1. python 3.9.7
2. Mac OS
3. Netlike 4.0.0

**from netmiko import ConnectHandler
from getpass import getpass
from pprint import pprint


cisco1 = {
    "device_type": "huawei",
    "host": "10.179.28.2",
    "username": "jmmorales",
    "password": getpass(),
}

command = "display version"
with ConnectHandler(**cisco1) as net_connect:
    print(net_connect.find_prompt())
    # Use TextFSM to retrieve structured data
    output = net_connect.send_command(command, use_textfsm=True)

#print()
pprint(output)
#print()

**   

Output

**Exception has occurred: ReadException
Unable to successfully split output based on pattern:
pattern=((Change now|Please choose))|([\]>]\s*$)
output='\nInfo: The max number of VTY users is 15, the number of current VTY users online is 2, and total number of terminal users online is 2.\n      The current login time is 2022-03-29 18:05:20-06:00.\nInfo: The device is not enabled with secure boot, please enable it.\n<GNCYGTAJN2D2C02B02EII1>'
results=['\nInfo: The max number of VTY users is 15, the number of current VTY users online is 2, and total number of terminal users online is 2.\n      The current login time is 2022-03-29 18:05:20-06:00.\nInfo: The device is not enabled with secure boot, please enable it.\n<GNCYGTAJN2D2C02B02EII1', None, None, '>', '']
  File "[/Volumes/Extreme]() SSD[/HP/Py/Interfaces]() LIBRES[/ssh-multiple-sessions-textfsm/send_command_textfsm-huawei.py]()", line 14, in <module>
    with ConnectHandler(**cisco1) as net_connect:**
Can one of you show me what the Huawei login looks like? In other words, if you login manually what does the CLI session look like?
Yeah sure,

There it is:

**jm@JMG-MBA ~ % ssh jmmorales@10.179.28.2  

+----------------------------------------------------------------+
| Este equipo es propiedad privada,                              |
| si no tiene autorizacion para ingresar al equipo, por favor    |
| cancele la conexion inmediatamente,cualquier anomalia sera     | 
| reportada a las autoridades correspondientes.                  |
+----------------------------------------------------------------+

User Authentication
(jmimorales@10.179.28.2) Enter password:

Warning: Negotiated identity key for server authentication is not safe. It is recommended that you disable the insecure algorithm or upgrade the client.

Info: The max number of VTY users is 15, the number of current VTY users online is 1, and total number of terminal users online is 1.
      The current login time is 2022-03-29 21:09:19-06:00.
Info: The device is not enabled with secure boot, please enable it.
GNCYGTAJN2D2C02B02EII1>
**
What is this ** after the prompt?

```
GNCYGTAJN2D2C02B02EII1>
**
```

Is that really there or was that an error in the posting above?
that was and error, those **** are not on the prompt.

Its because I wanna make the output to be in bold text.
I have the same problem after having cloned the repository to another computer.

on the computer where I create the rep. it's working fine

I'm using another version of pycharm

I managed to solve the problem.
I was connecting by ConnectionHandler and I switched to HuawelTelnet
Does Netmiko 3.4.0 work (i.e. is this only a Netmiko 4.0.0 issue)?

@migmorales22 
With netmiko 3.4.0 the data is not parse:

Here's the script:
from netmiko import ConnectHandler
from getpass import getpass
from pprint import pprint


cisco1 = {
    "device_type": "huawei",
    "host": "10.179.28.2",
    "username": "huawei",
    "password": getpass(),
}

command = "display version"
with ConnectHandler(**cisco1) as net_connect:
    output = net_connect.send_command(command, use_textfsm=True)

print(output)

Here is the output:

Huawei Versatile Routing Platform Software
VRP (R) software, Version 8.190 (NE40E V800R011C10SPC100)
Copyright (C) 2012-2019 Huawei Technologies Co., Ltd.
HUAWEI NE40E-M2K-B uptime is 350 days, 18 hours, 31 minutes 

NE40E-M2K-B version information:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BKP  version information:
  PCB        Version  : CX68BKP01D REV A
  IPU  Slot  Quantity : 1
  CARD Slot  Quantity : 3
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
IPU version information:

IPU (Master) 3 : uptime is 350 days, 18 hours, 31 minutes
  StartupTime 2021/04/13   18:22:50
  SDRAM Memory Size   : 16384 M bytes
  FLASH Memory Size   : 128 M bytes
  CFCARD Memory Size  : 4096 M bytes
  IPU CR5B0BKP0393 version information
  CPU PCB     Version : CX68E4NLAXFB REV B
  EPLD        Version : 004
  FPGA        Version : 009
  FPGA2       Version : 008
  NPU PCB     Version : CX68E4NLAXFA REV A
  FPGA        Version : 102
  FPGA2       Version : 007
  NP          Version : 100  
  TM          Version : 110
  NSE         Version : NSE REV A
  BootROM     Version : 04.73
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Power version information: 

POWER 4's version information:
  PCB     Version : CX68PSUF REV B

POWER 5's version information:
  PCB     Version : CX68PSUF REV B
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
FAN version information: 

FAN 6's version information:
  PCB     Version : CX68FCBD REV A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
CLK version information:

CLK 7 : uptime is 350 days, 18 hours, 31 minutes
  StartupTime 2021/04/13   18:22:50
  FPGA     Version : 1509
  DSP      Version : 17060021
(project1) josemiguelmorales@MIG-MBA ~ % 

With netmiko 4.0.0, and same script, the output is:

Exception has occurred: ReadException
Unable to successfully split output based on pattern:
pattern=((Change now|Please choose))|([\]>]\s*$)
output='\nInfo: The max number of VTY users is 11, the number of current VTY users online is 1, and total number of terminal users online is 1.\n      The current login time is 2022-03-30 12:56:58-04:00.\n      The last login time is 2022-03-30 12:53:46-04:00 from 181.209.150.62 through SSH.\n<MARLLC01>'
results=['\nInfo: The max number of VTY users is 11, the number of current VTY users online is 1, and total number of terminal users online is 1.\n      The current login time is 2022-03-30 12:56:58-04:00.\n      The last login time is 2022-03-30 12:53:46-04:00 from 181.209.150.62 through SSH.\n<MARLLC01', None, None, '>', '']
  File "[/Volumes/Extreme]() SSD[/HP/Py/Interfaces]() LIBRES[/ssh-multiple-sessions-textfsm/send_command_textfsm-huawei.py]()", line 14, in <module>
    with ConnectHandler(**cisco1) as net_connect:



@migmorales22 So in Netmiko 3.4.0, you connect, but your TextFSM parsing doesn't work properly (i.e. you have a different issue, but not a connection issue).

Is that correct?
Yes, that's correct,

With netmiko 3.4.0 its the textfsm that doesn't parse the output of the send command, and in netmiko 4.0.0 is the "Exception has occurred:ReadException"
I couldn't connect to Huawei devices after upgrading to V4.0.0 .
```
Connecting to 192.168.1.100:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

WARNING! The remote SSH server rejected X11 forwarding request.

Info: The max number of VTY users is 10, and the number
      of current VTY users on line is 1.
      The current login time is 2022-03-31 15:03:24+08:00.
Info: Lastest accessed IP: 192.168.1.100  Time: 2022-03-31 14:58:54+08:00  Password will expire in: -

Info: Smart-upgrade is currently disabled. Enable Smart-upgrade to get recommended version information.
<HUAWEI>
```
I have the same issue with Huawei device
New version V4.0.0 has problems with huawei devices.
@ktbyers 
I can confirm the issue using Netmiko 4.0.0 (latest pip release together with Python 3.10.4) using `device_type = 'huawei'`.

With the Netmiko 3.4.0 release everything works fine. Also, it doesn't seem to make any difference whether the password change prompt is displayed or not (see both tracebacks below).

```python
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=((Change now|Please choose))|([\]>]\s*$)
output='\nWarning: The password will expire in 11 days.\nThe password needs to be changed. Change now? [Y/N]: '
results=['\nWarning: The password will expire in 11 days.\nThe password needs to be changed. ', 'Change now', 'Change now', None, '? [Y/N]: ']
```

```python
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=((Change now|Please choose))|([\]>]\s*$)
output='\nInfo: Current mode: Monitor (automatically making switching decisions).\nWarning: The intelligent upgrade function is disabled. Log in to the web platform and enable this function.\n  -----------------------------------------------------------------------------     \n  User last login information:     [...]      \n  -----------------------------------------------------------------------------\n<AC6508>'
results=['\nInfo: Current mode: Monitor (automatically making switching decisions).\nWarning: The intelligent upgrade function is disabled. Log in to the web platform and enable this function.\n  -----------------------------------------------------------------------------     \n  User last login information:     [...]    \n  -----------------------------------------------------------------------------\n<AC6508', None, None, '>', '']
```

After spending some time investigating the issue I found out that the pattern matching logic in `read_until_pattern` expects the pattern to split exactly in 3 parts (using re.split), see [base_connection.py#L579](https://github.com/ktbyers/netmiko/blob/c76d09fad12c98b1e70176906a4129a53d9be06c/netmiko/base_connection.py#L624) for reference. Seems this change was introduced during some fundamental changes to the channel reading logic in in https://github.com/ktbyers/netmiko/commit/793100dcfd76d3eb5089ba4cd27c99e3c3c0f886.

I have proposed a fix and documented some more info in #2719.



> 

When will the new version be released.
@luweijun1992 Just pin to Netmiko 3.4.0 or directly use the proposed fix from Git (i.e. you don't need a new release to work around this).
> @luweijun1992 Just pin to Netmiko 3.4.0 or directly use the proposed fix from Git (i.e. you don't need a new release to work around this).

I installed it using pip, do you mean rollback version v3.4.0?
Still want to use the new version, need the new function send_multiline()
@luweijun1992 You could use my proposed fix directly with pip like below until a fixed Netmiko version is available.

```sh
pip install 'git+https://github.com/fharbe/netmiko.git@fix_huawei_login#egg=netmiko'
```
Updated PR here:

https://github.com/ktbyers/netmiko/pull/2728

Can anyone test that this works properly?
@luweijun1992 @pyhas @migmorales22 @nivaldoinacios @quinnhao Let me know is someone can test the PR here:

#2728 

I want to try to include this in a Netmiko release that I would release shortly.


Thanks, Kirk
> @luweijun1992 @pyhas @migmorales22 @nivaldoinacios @quinnhao Let me know is someone can test the PR here:
> 
> #2728
> 
> I want to try to include this in a Netmiko release that I would release shortly.
> 
> Thanks, Kirk

Looking forward to the release of the new version, I go back to the old version v3.4.0
@luweijun1992 Yep, I need someone to test that it fixes the issue. Can you do that?
> @luweijun1992 Yep, I need someone to test that it fixes the issue. Can you do that?

No problem, I will test the new release.
Yeah, I really need someone to test it beforehand i.e. before it gets merged into `develop` (and before there is a release).
> Yeah, I really need someone to test it beforehand i.e. before it gets merged into `develop` (and before there is a release).

Please tell me how to cooperate with you for the test.
Maybe you can send me the fixed file and I'll overwrite the old file for testing.
@luweijun1992 pip install it and see if the previous failure occurs or not.

You can pip install a specific commit. You can also pip install a branch. Some of this pip syntax is confusing, but should be available online. I usually do:

```
git clone <repo>
cd <repo>
pip uninstall netmiko
pip install -e .
```

i.e. I usually just install it from the local repository. You have to make sure you clone the right location. I will merge into the `develop` branch (right now). So the above should work (as git will clone the `develop` branch automatically).
> @luweijun1992 pip install it and see if the previous failure occurs or not.
> 
> You can pip install a specific commit. You can also pip install a branch. Some of this pip syntax is confusing, but should be available online. I usually do:
> 
> ```
> git clone <repo>
> cd <repo>
> pip uninstall netmiko
> pip install -e .
> ```
> 
> i.e. I usually just install it from the local repository. You have to make sure you clone the right location. I will merge into the `develop` branch (right now). So the above should work (as git will clone the `develop` branch automatically).
```
git clone https://github.com/ktbyers/netmiko.git
cd netmiko
pip install -e .
```
![image](https://user-images.githubusercontent.com/58923704/163501634-760b9200-902a-476e-bc60-863dd000db3c.png)

```
[Running] python -u "d:\ssh_conn.py"
Traceback (most recent call last):
  File "d:\ssh_conn.py", line 26, in <module>
    with ConnectHandler(**huawei) as net_connect:
  File "d:\netmiko\netmiko\ssh_dispatcher.py", line 344, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "d:\netmiko\netmiko\base_connection.py", line 434, in __init__
    self._open()
  File "d:\netmiko\netmiko\base_connection.py", line 439, in _open
    self.establish_connection()
  File "d:\netmiko\netmiko\base_connection.py", line 1092, in establish_connection
    self.special_login_handler()
  File "d:\netmiko\netmiko\huawei\huawei.py", line 18, in special_login_handler
    data = self.read_until_pattern(pattern=rf"({password_change_prompt}|[>\]])")
  File "d:\netmiko\netmiko\base_connection.py", line 631, in read_until_pattern
    raise ReadException(msg)
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=((Change now|Please choose)|[>\]])
output='\nInfo: The max number of VTY users is 10, and the number\n      of current VTY users on line is 1.\n      The current login time is 2009-02-09 21:53:27+08:00.\n<S5700-10P>'
results=['\nInfo: The max number of VTY users is 10, and the number\n      of current VTY users on line is 1.\n      The current login time is 2009-02-09 21:53:27+08:00.\n<S5700-10P', '>', None, '']


[Done] exited with code=1 in 8.166 seconds
```
![image](https://user-images.githubusercontent.com/58923704/163501461-88ebee78-87e0-4aee-b367-3336712eb438.png)


@luweijun1992 Okay, great thanks for testing.

I have a new fix here:

https://github.com/ktbyers/netmiko/pull/2737

This has been merged into `develop`.

You should be able to update your code that you are testing with by doing.

```
cd <github repo directory>
git fetch origin
git rebase origin/develop
```

This assumes you still have the `develop` branch checked out (which you should).
If you could re-test this new fix, that would be very helpful.
> @luweijun1992 Okay, great thanks for testing.
> 
> I have a new fix here:
> 
> #2737
> 
> This has been merged into `develop`.
> 
> You should be able to update your code that you are testing with by doing.
> 
> ```
> cd <github repo directory>
> git fetch origin
> git rebase origin/develop
> ```
> 
> This assumes you still have the `develop` branch checked out (which you should).
The test was successful.
![image](https://user-images.githubusercontent.com/58923704/163507689-b560b670-55b4-44b0-9841-78f2b1202e5a.png)

![image](https://user-images.githubusercontent.com/58923704/163507714-b281fed6-e119-4ed8-a01e-fe7db0911ba0.png)

> @luweijun1992 Okay, great thanks for testing.
> 
> I have a new fix here:
> 
> #2737
> 
> This has been merged into `develop`.
> 
> You should be able to update your code that you are testing with by doing.
> 
> ```
> cd <github repo directory>
> git fetch origin
> git rebase origin/develop
> ```
> 
> This assumes you still have the `develop` branch checked out (which you should).

But the result of print seems abnormal.
```
print(result)
```
![image](https://user-images.githubusercontent.com/58923704/163507994-dbecb85f-4f4c-46eb-a6ae-baf99180de7d.png)

Hello!
@ktbyers 4.1.0 is ok work ssh, problem use huawei_telnet
```
Traceback (most recent call last):
  File "/home/mikholap/Рабочий стол/my-projects/mikholap-scripts/core and aggregation/asw_vlan_probros_pub.py", line 17, in <module>
    net_connect = ConnectHandler(**device)
  File "/home/mikholap/.local/lib/python3.10/site-packages/netmiko/ssh_dispatcher.py", line 344, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/mikholap/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 434, in __init__
    self._open()
  File "/home/mikholap/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 439, in _open
    self.establish_connection()
  File "/home/mikholap/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 1009, in establish_connection
    self.telnet_login()
  File "/home/mikholap/.local/lib/python3.10/site-packages/netmiko/huawei/huawei.py", line 150, in telnet_login
    output = self.read_until_pattern(pattern=combined_pattern)
  File "/home/mikholap/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 631, in read_until_pattern
    raise ReadException(msg)
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=(]\s*$|>\s*$|(Change now|Please choose 'YES' or 'NO').+)
output=':\nInfo: The max number of VTY users is 10, and the number\n      of current VTY users on line is 2.\n      The current login time is 2022-05-13 13:46:34+04:00.\nInfo: Smart-upgrade is currently disabled. Enable Smart-upgrade to get recommended version information.\n<***>'
results=[':\nInfo: The max number of VTY users is 10, and the number\n      of current VTY users on line is 2.\n      The current login time is 2022-05-13 13:46:34+04:00.\nInfo: Smart-upgrade is currently disabled. Enable Smart-upgrade to get recommended version information.\n<***', '>', None, '']
```
@aztec102 So you are still seeing an issue when you suing Huawei and telnet with Netmiko 4.1.0?
@ktbyers  Yes, i see.
```
import re
from netmiko import ConnectHandler
host = input('Input Dest host: ')

device = {
    'device_type': 'huawei_telnet',
    'ip':   host,
    'username': 'login',
    'password': 'pass',
    'port' : 23,
    'verbose': True,
    'session_log': f'{host}.log'
}

net_connect = ConnectHandler(**device)
```

```
pip3 list | grep netmiko
netmiko                      4.1.0
```
Hi！MR.Ktbyers！I have the same issue with H3C(hp_comware_telnet) .
SSH(hp_comware) was perfect ! I like it ! but telnet never succeeded.
******************************************************************
from netmiko import ConnectHandler

dev = {
    'device_type': "hp_comware_telnet",
    'host': '192.168.11.1',
    'username': 'admin',
    'password': 'admin',
    'port': 23,
}
net_con = ConnectHandler(**dev)
output = net_con.send_command('display current-configuration')
print(output)
**********************************************************************
Traceback (most recent call last):
  File "C:\Users\18592\AppData\Roaming\JetBrains\PyCharm2022.1\scratches\scratch_6.py", line 10, in <module>
    net_con = ConnectHandler(**dev)
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\ssh_dispatcher.py", line 351, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\hp\hp_comware.py", line 145, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\hp\hp_comware.py", line 13, in __init__
    super().__init__(**kwargs)
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\base_connection.py", line 434, in __init__
    self._open()
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\base_connection.py", line 440, in _open
    self._try_session_preparation()
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\base_connection.py", line 879, in _try_session_preparation
    self.session_preparation()
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\hp\hp_comware.py", line 19, in session_preparation
    data = self._test_channel_read(pattern=r"to continue|[>\]]")
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\base_connection.py", line 1119, in _test_channel_read
    return self.read_until_pattern(pattern=pattern, read_timeout=20)
  File "C:\Users\18592\PycharmProjects\thearding\venv\lib\site-packages\netmiko\base_connection.py", line 651, in read_until_pattern
    raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout: 

Pattern not detected: 'to continue|[>\\]]' in output.

Things you might try to fix this:
1. Adjust the regex pattern to better identify the terminating string. Note, in
many situations the pattern is automatically based on the network device's prompt.
2. Increase the read_timeout to a larger value.

You can also look at the Netmiko session_log or debug log for more information.
******************************************************************************************
1、windows 10
2、python3.10.4
3、netmiko 4.1.1
THANK YOU!






@zhtjames Can you show me what a manual telnet looks like i.e. copy and paste the manual telnet session here. You can obscure/change your username and password or anything else that is confidential.
@zhtjames ???
@ktbyers, you are great, thank you for netmiko!
I faced the same issue when try telnet. Below is manual telnet session you asked for:
```
user@my-secret-host:~$ telnet 10.166.66.66
Trying 10.166.66.66...
Connected to 10.166.66.66.
Escape character is '^]'.

Warning: Telnet is not a secure protocol, and it is recommended to use Stelnet.

Login authentication


Username:my-secret-username
Password:
Info: The max number of VTY users is 5, and the number
      of current VTY users on line is 1.
<my-secret-prompt>
<my-secret-prompt>quit
Info: The max number of VTY users is 5, and the number
      of current VTY users on line is 0.Connection closed by foreign host.
user@my-secret-host:~$
```
Python code:
```python
from netmiko import ConnectHandler

device = {
    'device_type': 'huawei_telnet',
    'host': '10.166.66.66',
    'username': 'my-secret-username',
    'password': 'my-secret-password',
}

net_connect = ConnectHandler(**device)
net_connect.disconnect()
```
Exception:
```
Traceback (most recent call last):
  File "issue.py", line 10, in <module>
    net_connect = ConnectHandler(**device)
  File "/home/user/.local/lib/python3.8/site-packages/netmiko/ssh_dispatcher.py", line 365, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/netmiko/base_connection.py", line 439, in __init__
    self._open()
  File "/home/user/.local/lib/python3.8/site-packages/netmiko/base_connection.py", line 444, in _open
    self.establish_connection()
  File "/home/user/.local/lib/python3.8/site-packages/netmiko/base_connection.py", line 1034, in establish_connection
    self.telnet_login()
  File "/home/user/.local/lib/python3.8/site-packages/netmiko/huawei/huawei.py", line 155, in telnet_login
    output = self.read_until_pattern(pattern=combined_pattern)
  File "/home/user/.local/lib/python3.8/site-packages/netmiko/base_connection.py", line 672, in read_until_pattern
    raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout: 

Pattern not detected: "(]\\s*$|>\\s*$|(Change now|Please choose 'YES' or 'NO').+)" in output.

Things you might try to fix this:
1. Adjust the regex pattern to better identify the terminating string. Note, in
many situations the pattern is automatically based on the network device's prompt.
2. Increase the read_timeout to a larger value.

You can also look at the Netmiko session_log or debug log for more information.
```
Configuration:
```
netmiko==4.1.2
Python 3.8.10
Linux Mint 20.3
```


@TimGa Is it possible that you can look in the debugger and see what happened right before this:

https://github.com/ktbyers/netmiko/blob/develop/netmiko/huawei/huawei.py#L155

i.e. add a Pdb debug breakpoint right before this and see what is in the `return_msg` variable?

The failure above says it failed on the looking for `>` which should be in the output after the password is sent.

Here is `return_msg` content:
```

Warning: Telnet is not a secure protocol, and it is recommended to use Stelnet.


Login authentication


Username:my-secret-username
Password
```
It turned out that password in my python script was incorrect - I mixed up IPs and passwords of different devices while investigation. As far as I understood, ReadTimeout raises while waiting for pattern after incorrect password. And it looks like that in my case the reason for timeout is that device has big delay between asking for password re-entry.
Here is manual telnet with incorrect password, just in case:
```
Trying 10.166.66.66...
Connected to 10.166.66.66.
Escape character is '^]'.

Warning: Telnet is not a secure protocol, and it is recommended to use Stelnet.

Login authentication


Username:my-secret-username
Password:
Error: Local authentication is rejected

Username:my-secret-username
Password:
Error: Local authentication is rejected

Username:my-secret-username
Password:
Error: Local authentication is rejected
Connection closed by foreign host.
```
P.S. Sorry for the confusion! I was confused with "ReadTimeout:Pattern not detected:" and didn't even think about password issue, cause usually it is NetmikoAuthenticationException. So maybe it is better to raise auth instead of timeout in such situation, but offcourse it is up to you to decide.
 **Important**: Actual problem is still remains - I can't connect to some huawei device using telnet, but actual error is not `ReadTimeout` but `ReadException: Unable to successfully split output based on pattern`. I'll try to investigate it and write results here in few days.
I am going to leave this open and flag at it as an issue where improvement should be made.

1. Better error message.
2. Potentially more reliable loop behavior.
Hi all,

I seem to be running into this issue as well since the new version:

 ```Traceback (most recent call last):
  File "/home/<snip>/devops/test-development/network/huawei_bulk_patch.py", line 19, in <module>
    print(net_connect = ConnectHandler(**device))
  File "/home/<snip>/.local/lib/python3.10/site-packages/netmiko/ssh_dispatcher.py", line 365, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "/home/<snip>/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 439, in __init__
    self._open()
  File "/home/<snip>/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 444, in _open
    self.establish_connection()
  File "/home/<snip>/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 1034, in establish_connection
    self.telnet_login()
  File "/home/<snip>/.local/lib/python3.10/site-packages/netmiko/huawei/huawei.py", line 155, in telnet_login
    output = self.read_until_pattern(pattern=combined_pattern)
  File "/home/<snip>/.local/lib/python3.10/site-packages/netmiko/base_connection.py", line 652, in read_until_pattern
    raise ReadException(msg)
netmiko.exceptions.ReadException: Unable to successfully split output based on pattern:
pattern=(]\s*$|>\s*$|(Change now|Please choose 'YES' or 'NO').+)
output=':\n  -----------------------------------------------------------------------------     \n  User last login information:     \n  -----------------------------------------------------------------------------\n  Access Type: Telnet      \n  IP-Address : <snip>     \n  Time       : 2022-08-29 11:21:20+02:00 DST     \n  -----------------------------------------------------------------------------\n<support-network-labo-ar1220>'
results=[':\n  -----------------------------------------------------------------------------     \n  User last login information:     \n  -----------------------------------------------------------------------------\n  Access Type: Telnet      \n  IP-Address : <snip>     \n  Time       : 2022-08-29 11:21:20+02:00 DST     \n  -----------------------------------------------------------------------------\n<support-network-labo-ar1220', '>', None, '']
```

Environment: Ubuntu 22.04.1
Python 3.10.4
netmiko            4.1.2

How can I help to investigate this? (not the best coder in the world but I will try to do my best)

Resolving patch:
diff --git a/netmiko/huawei/huawei.py b/netmiko/huawei/huawei.py
--- a/netmiko/huawei/huawei.py
+++ b/netmiko/huawei/huawei.py
@@ -128,7 +128,7 @@ def telnet_login(
         """Telnet login for Huawei Devices"""
 
         delay_factor = self.select_delay_factor(delay_factor)
-        password_change_prompt = r"(Change now|Please choose 'YES' or 'NO').+"
+        password_change_prompt = r"(?:Change now|Please choose 'YES' or 'NO').+"
         combined_pattern = r"({}|{}|{})".format(
             pri_prompt_terminator, alt_prompt_terminator, password_change_prompt
         )


Test patch: