3
votes

I'm currently working my way through a book called Mastering Python networking by Eric Chou (I'm a network engineer).

One of the examples provides sample code to use netconf to connect to a Cisco Nexus device but upon trying to connect I am getting the below errors in relation to:

AttributeError: '_RSAPublicKey' object has no attribute 'verify'

Could anyone advise on what may be the issue.

I have the latest version of Python3 installed on Ubuntu 16.04 LTS and as per instructions in the book downloaded and installed the latest version of ncclient.

Incidentally I am connecting to the Cisco Devnet Nexus NX-API sandbox simulator, also a manual ssh terminal connection using the credentials show in the code below works fine.

Upon running the following code:

from ncclient import manager
conn=manager.connect(
 host='sbx-nxos-mgmt.cisco.com',
 port=8181,
 username='admin',
 password='Admin_1234!',
 hostkey_verify=False,
 device_params={'name': 'nexus'},
 look_for_keys=False
)

I get the below errors:

Unknown exception: '_RSAPublicKey' object has no attribute 'verify' Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 1925, in run self.kex_engine.parse_next(ptype, m) File "/usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py", line 47, in parse_next return self._parse_kexecdh_reply(m) File "/usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py", line 107, in _parse_kexecdh_reply self.transport._verify_key(K_S, sig) File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 1750, in _verify_key if not key.verify_ssh_sig(self.H, Message(sig)): File "/usr/local/lib/python3.5/dist-packages/paramiko/rsakey.py", line 127, in verify_ssh_sig key.verify( AttributeError: '_RSAPublicKey' object has no attribute 'verify'

Traceback (most recent call last): File "", line 8, in File "/usr/local/lib/python3.5/dist-packages/ncclient-0.5.3-py3.5.egg/ncclient/manager.py", line 155, in connect File "/usr/local/lib/python3.5/dist-packages/ncclient-0.5.3-py3.5.egg/ncclient/manager.py", line 120, in connect_ssh File "/usr/local/lib/python3.5/dist-packages/ncclient-0.5.3-py3.5.egg/ncclient/transport/ssh.py", line 409, in connect File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 545, in start_client raise e File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 1925, in run self.kex_engine.parse_next(ptype, m) File "/usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py", line 47, in parse_next return self._parse_kexecdh_reply(m) File "/usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py", line 107, in _parse_kexecdh_reply self.transport._verify_key(K_S, sig) File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 1750, in _verify_key if not key.verify_ssh_sig(self.H, Message(sig)): File "/usr/local/lib/python3.5/dist-packages/paramiko/rsakey.py", line 127, in verify_ssh_sig key.verify( AttributeError: '_RSAPublicKey' object has no attribute 'verify'

2
Thanks Simon appreciate that and will do so the next time I post.. - DanM

2 Answers

0
votes

Just a followup note from the last update, the directory ncclient was cloned from the following git repository:

$ git clone https://github.com/ncclient/ncclient
$ cd ncclient/
$ sudo python3 setup.py install

The Cisco client script can be seen on the book github repo here, https://github.com/PacktPublishing/Mastering-Python-Networking/blob/master/Chapter03/Cisco/cisco_nxapi_1.py.

Eric

0
votes

Update:

I also reached out to the author of the book I am working from (Eric Chou (Mastering Python Networking)). Eric kindly replied showing the steps he took to replicate the code and the relevant dependencies he also installed on his Ubuntu host.

Once I also (re)installed the same list of packages/dependencies on my Ubuntu host the code worked/error cleared so I must have obviously been missing one or more of the below.

If anyone encounters similar then I took the below steps to fix the errors I was seeing:

sudo apt-get install -y python3-dev libxml2-dev libxslt1-dev libffi-dev libssl-dev zlib1g-dev python3-pip git python3-requests
cd ncclient/
ncclient$ sudo python3 setup.py install