Open ghost opened 3 years ago
FYI @neelimapp
Also if anyone knows why these ssh args were even required, and if there's something I can do to not require them, I would be interested.
@d-gagne allow_agent should probably default to False.
The other two are better security i.e. you potentially shouldn't blindly trust SSH host keys.
How do I explicitly trust the SSH host keys?
You securely put the "known SSH hosts" in a file and you tell your SSH library that the hosts whose identities are specified in that file are trusted.
I'm seeing this exact same message (authentication failure) when running from a script as well, I have noted the following, which may be a pointer to the base issue though, let me know if you need more info.
This works --> ssh -p 830 -s admin@xr.device.com netconf This fails --> ssh -p 830 admin@xr.device.com netconf
The '-s' --> straight from the man page -s May be used to request invocation of a subsystem on the remote system. Subsystems facilitate the use of SSH as a secure trans‐ port for other applications (e.g. sftp(1)). The subsystem is specified as the remote command.
Above command error Password: Received disconnect from xr.device.com port 830:11: Disconnected from xr.device.com port 830
Error from the script mirrors the above error. Salient point from it --> raise AuthenticationError(repr(saved_exception)) ncclient.transport.errors.AuthenticationError: SSHException('No existing session',)
Device ver: Wed Jul 7 03:41:47.121 UTC Cisco IOS XR Software, Version 7.1.3 Copyright (c) 2013-2020 by Cisco Systems, Inc.
Build Information: Built By : gopalk2 Built On : Thu Nov 26 10:51:48 PST 2020 Built Host : iox-ucs-027 Workspace : /auto/srcarchive17/prod/7.1.3/asr9k-x64/ws Version : 7.1.3 Location : /opt/cisco/XR/packages/ Label : 7.1.3
cisco ASR9K () processor System uptime is 11 weeks 6 days 7 hours 22 minutes
pip freeze | grep napalm napalm==3.3.1
@Tree2w63 Your message/issue sounds unrelated to NAPALM's IOS-XR driver? What is the relevance of your post here?
Script fails at open from napalm import get_network_driver
optional_args = {
#'config_encoding': 'xml',
'config_encoding': 'cli',
#'port': 830,
} device = { "hostname": "xr.device.com", "username": "admin", "password": "password",
}
driver = get_network_driver("iosxr_netconf") dev = driver(**device) dev.open()
Here is the complete output from above
]# bin/test_iosxr_netconf.py SSHException('No existing session',) Traceback (most recent call last): File "/opt/ConfigAuto/lib64/python3.6/site-packages/napalm/iosxr_netconf/iosxr_netconf.py", line 93, in open device_params={"name": "iosxr"}, File "/opt/ConfigAuto/lib64/python3.6/site-packages/ncclient/manager.py", line 168, in connect return connect_ssh(*args, *kwds) File "/opt/ConfigAuto/lib64/python3.6/site-packages/ncclient/manager.py", line 135, in connect_ssh session.connect(args, **kwds) File "/opt/ConfigAuto/lib64/python3.6/site-packages/ncclient/transport/ssh.py", line 362, in connect self._auth(username, password, key_filenames, allow_agent, look_for_keys) File "/opt/ConfigAuto/lib64/python3.6/site-packages/ncclient/transport/ssh.py", line 464, in _auth raise AuthenticationError(repr(saved_exception)) ncclient.transport.errors.AuthenticationError: SSHException('No existing session',)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bin/test_iosxr_netconf.py", line 21, in
You have to specify port 830. it looks like you are trying to connect on port 22?
Nevermind...it defaults to port 830 in the driver.
Is the remote host in SSH known hosts?
Does it work if you add: hostkey_verify=False,
into the manager.connect() call here:
https://github.com/napalm-automation/napalm/blob/develop/napalm/iosxr_netconf/iosxr_netconf.py#L93
it was one of the optional args I tried, with no difference in the outcome
optional_args won't work, you would have modify the code at the location that I pointed to (or add the relevant entry in SSH known-hosts).
Actually, you might want to try the following three entries:
hostkey_verify=False,
look_for_keys=False,
allow_agent=False,
That would be interesting to know if it fixes your issue. Those items fixed the original issue that was reported by the original user.
no difference with the below, but using the same via ncclient manager works
from napalm import get_network_driver
optional_args = { 'allow_agent': False, 'hostkey_verify': False, 'look_for_keys': False, } device = { "hostname": "xr.device.com", "username": "admin", "password": "password", "optional_args": optional_args, }
driver = get_network_driver("iosxr_netconf") device = driver(**device) device.open()
optional_args won't work...they aren't wired in. You have to edit the python code (if you want to test them).
You would have to edit them in here:
https://github.com/napalm-automation/napalm/blob/develop/napalm/iosxr_netconf/iosxr_netconf.py#L93
Thank you, I'll add it to my local copy, going forward is this a patch that will be done, or will I need to document / highlight this, etc, so that when I update, I remember to update this as well.
Just to confirm, that resolved it for me
Okay, thanks for letting us know...we should make some fixes to the IOS-XR driver to change some of these defaults and to allow some of these to be passed via optional_args.
I'm running into this as a blocker as well, are there any updates on passing optional arguments? Patching the underlying driver isn't a solution as we have multiple users running the code locally and it isn't feasible to patch on each environment
@OsirisS13 Someone would need to implement a fix for this (so far no one has done it). It is probably pretty straight-forward to do.
@ktbyers I've submitted pull request #1535 to resolve this issue. As noted in the PR the solution bypasses the netmiko_helpers netmiko_args() function for this particular use case.
@ktbyers there's been no movement on the pull request I've submitted to resolve this issue. Is there something else I need to do to have it reviewed and merged? First time contributing to a project like this so I'm not sure of the process
No, it is just me. Let me see if I can do this in the next week.
IOSXR_NETCONF SSHException, optional args do not work
When connecting via iosxr_netconf I get an exception:
napalm.base.exceptions.ConnectionException: SSHException('No existing session')
I can get it to work by modifying iosxr_netconf.py to force it to use the optional args:
But iosxr_netconf doesn't use those optional args if you attempt to supply them using
--optional_args 'hostkey_verify=False, look_for_keys=False, allow_agent=False'
Also doesn't work if you use them via optional args in the driver init.
Did you follow the steps from https://github.com/napalm-automation/napalm#faq
(Place an
x
between the square brackets where applicable)Setup
napalm version
(Paste verbatim output from
pip freeze | grep napalm
between quotes below)Network operating system version
(Paste verbatim output from
show version
- or equivalent - between quotes below)Steps to Reproduce the Issue
napalm --vendor iosxr_netconf --user $user --password $pw $host call get_facts
Error Traceback
(Paste the complete traceback of the exception between quotes below)