ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.63k stars 1.31k forks source link

fiberstore_fsos authentication failure #3366

Open tvphuocjp opened 10 months ago

tvphuocjp commented 10 months ago

Description of Issue/Question

Cannot to connect Fiberstore switch via Netmiko, when using paramiko is OK. Exception: Bad authentication type; allowed types: ['publickey', 'password']

Netmiko device_type (if relevant to the issue)

(Paste device_type between quotes below)

fiberstore_fsos

Steps to Reproduce the Issue

Error Traceback

(Paste the complete traceback of the exception between quotes below)

_Traceback (most recent call last):
  File "D:\*******\task_ping_tracert.py", line 20, in <module>
    get_ip_brief(router)
  File "D:\*******\task_ping_tracert.py", line 11, in get_ip_brief
    conn =  netmiko.ConnectHandler(**device_info, conn_timeout = 600)
  File "C:\Users\*******\AppData\Roaming\Python\Python39\site-packages\netmiko\ssh_dispatcher.py", line 399, in ConnectHandler
    return ConnectionClass(*args, **kwargs)
  File "C:\Users\*******\AppData\Roaming\Python\Python39\site-packages\netmiko\base_connection.py", line 488, in __init__
    self._open()
  File "C:\Users\*******\AppData\Roaming\Python\Python39\site-packages\netmiko\base_connection.py", line 493, in _open
    self.establish_connection()
  File "C:\Users\*******\AppData\Roaming\Python\Python39\site-packages\netmiko\base_connection.py", line 1174, in establish_connection
    raise NetmikoAuthenticationException(msg)
netmiko.exceptions.NetmikoAuthenticationException: Authentication to device failed.

Common causes of this problem are:
1. Invalid username and password
2. Incorrect SSH-key file
3. Connecting to the wrong device

Device settings: fiberstore_fsos 192.168.100.20:22

Bad authentication type; allowed types: ['publickey', 'password']_

Relevant Python code

(Please try to essentialize your Python code to the minimum code needed to reproduce the issue) (Paste the code between the quotes below)

import netmiko

list_router = { 
    "192.168.100.20" : "FS-SW-KNVT-BC122",
}

def get_ip_brief(router):
    device_info = {"ip": router, "port": 22, "username": "******", "password": "******", "device_type": "fiberstore_fsos"}
    conn =  netmiko.ConnectHandler(**device_info, conn_timeout = 600)
    print(f"Connect to {list_router[router]} successfully")
    prompt = conn.find_prompt()
    print(prompt)
    output = conn.send_command(f"show ip interface brief", expect_string= prompt)
    print(output.split("\n"))
    conn.disconnect()

for router in list_router:
    get_ip_brief(router)
ktbyers commented 10 months ago

Try setting fast_cli=False as an argument to your device_info device dictionary.

device_info = {
    "ip": router,
    "port": 22,
    "username": "******",
    "password": "******",
    "device_type": "fiberstore_fsos",
    "fast_cli": False,
}
tvphuocjp commented 10 months ago

Dear Sir,

I 've tried to add fast_cli=False but it's not OK. I use netmiko 4.3.0

netmiko.exceptions.NetmikoAuthenticationException: Authentication to device failed.

Common causes of this problem are:

  1. Invalid username and password
  2. Incorrect SSH-key file
  3. Connecting to the wrong device

Device settings: fiberstore_fsos ....***:22

File "", line 1, in AttributeError: module 'netmiko' has no attribute 'version'

netmiko.version '4.3.0'

ktbyers commented 10 months ago

Okay, how about:

device_info = {
    "ip": router,
    "port": 22,
    "username": "******",
    "password": "******",
    "device_type": "fiberstore_fsos",
    "fast_cli": False,
    "global_delay_factor": 2,    # Added
    "default_enter": "\r",           # Added
}
tvphuocjp commented 10 months ago

I try your suggestion, but it doesn't work. def get_ip_brief(router): device_info = {"ip": router, "port": 22, "username": "", "password": "", "device_type": "fiberstore_fsos", "fast_cli": False, "global_delay_factor": 2, "default_enter": "\r"} conn = netmiko.ConnectHandler(device_info, conn_timeout = 600) conn = netmiko.ConnectHandler(device_info, conn_timeout = 600) print(f"Connect to {list_router[router]} successfully") prompt = conn.find_prompt() x = datetime.datetime.now() year = (x.strftime("%Y")) month = (x.strftime("%m")) day = (x.strftime("%d")) print(prompt) cmd1 = f"ping 8.8.8.8 source {router} ntimes 10\n" output1 = conn.send_command(f"ping 8.8.8.8 source {router} ntimes 10", expect_string= prompt, read_timeout=300)

print(output1.split("\n"))

cmd2 = f"traceroute 8.8.8.8 source {router}\n"
output2 = conn.send_command(f"traceroute 8.8.8.8 source {router}", expect_string= prompt, read_timeout=300)
#print(output2.split("\n"))
conn.disconnect()

Output

netmiko.exceptions.NetmikoAuthenticationException: Authentication to device failed.

Common causes of this problem are:

  1. Invalid username and password
  2. Incorrect SSH-key file
  3. Connecting to the wrong device

Device settings: fiberstore_fsos ....***:22

Bad authentication type; allowed types: ['publickey', 'password'] ubuntu22:~/pingtracert#

tvphuocjp commented 10 months ago

Hi @ktbyers ,

What should I do next? Please give me some advices.

tvphuocjp commented 9 months ago

Hello @ktbyers any news ? :)