Unable to establish connection without known_hosts file
Closed this issue · 6 comments
Hello,
I faced an issue that I cannot connect to the router with pySROS without checking SSH key. Connection fails with this message:
RuntimeError: Cannot create connection - Unknown host key [omitted] for [ip.add.re.ss]
as I do not have known_hosts file.
Tried to add 'hostkey_verify=False'
as a parameter to connect()
function, but it didn't work: TypeError: connect() got an unexpected keyword argument 'hostkey_verify'
Looks like adding 'hostkey_verify=False'
to Connection object here solves the issue.
Could you please implement that?
Some info about the setup:
python3.6
pysros==21.7.2
router IXR7250-e 21.7.R1
host "CentOS Linux 7 (Core)"
See #3:
By adding 'kwargs' to connect, you can set additional parameters such as hostkey_verify
I didn't see that there is an open issue already before creating the pull request: #5
I just simply added the hostkey_verify parameter when calling the ncclient connection.
I didn't see that there is an open issue already before creating the pull request: #5
I just simply added the hostkey_verify parameter when calling the ncclient connection.
No problem. I'll close the PR. Please raise improvements via the Nokia support process.
I didn't see that there is an open issue already before creating the pull request: #5
I just simply added the hostkey_verify parameter when calling the ncclient connection.No problem. I'll close the PR. Please raise improvements via the Nokia support process.
Strange you closed the PR even you know it fixes a serious issue, I will simply fix it on my local copy :) good luck
FYI for future reference you can use it like thisto define any paramiko arguments you want without modifying pysros
from pysros.management import Connection
conn = Connection(
host=host,
username='admin',
key_filename = '/home/me/.ssh/key',
ssh_config = '/dev/null',
rebuild=False,
yang_directory='./YANG/',
hostkey_verify = False,
device_params={'name': 'sros'},
manager_params={'timeout': 300},
nc_params={'capabilities':['urn:nokia.com:nc:pysros:pc']}
)
This feature is included in release 22.7.1. Add the hostkey_verify=False argument to the connect method. Not recommended for use in a live environment.