Repository navigation
Closed
Description
simply running nornir with following command
devdsk.run(task=netmiko_file_transfer, source_file='./test_sbc_cert_file.pem', dest_file='/tmp/test_sbc_cert_file.pem')
Name: netmiko
Version: 4.0.0
Summary: Multi-vendor library to simplify legacy CLI connections to network devices
Home-page: https://github.com/ktbyers/netmiko
Author: Kirk Byers
Author-email: [email protected]
License: MIT
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: paramiko, ntc-templates, pyserial, tenacity, scp, textfsm, setuptools
Required-by: nornir-netmiko
Name: nornir
Version: 3.2.0
Summary: Pluggable multi-threaded framework with inventory management to help operate collections of devices
Home-page: https://github.com/nornir-automation/nornir
Author: David Barroso
Author-email: [email protected]
License: Apache 2.0
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: mypy_extensions, ruamel.yaml, typing_extensions
Required-by: nornir-utils
Pramiko 2.10.3 Does not work with cert authentication
Name: paramiko
Version: 2.10.3
Summary: SSH2 protocol library
Home-page: https://paramiko.org
Author: Jeff Forcier
Author-email: [email protected]
License: LGPL
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: bcrypt, cryptography, six, pynacl
Required-by: scp, netmiko
INFO:nornir.core:Running task 'netmiko_file_transfer' with args {'source_file': './test_sbc_cert_file.pem', 'dest_file': '/tmp/test_sbc_cert_file.pem'} on 1 hosts
DEBUG:nornir.core.task:Host 'devdsk': running task 'netmiko_file_transfer'
DEBUG:paramiko.transport:starting thread (client mode): 0xc9bdc60
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.10.3
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_7.4
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_7.4)
DEBUG:paramiko.transport:=== Key exchange possibilities ===
DEBUG:paramiko.transport:kex algos: curve25519-sha256, [email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha256, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
DEBUG:paramiko.transport:server key: ssh-rsa, rsa-sha2-512, rsa-sha2-256, ecdsa-sha2-nistp256, ssh-ed25519
DEBUG:paramiko.transport:client encrypt: [email protected], aes128-ctr, aes192-ctr, aes256-ctr, [email protected], [email protected], aes128-cbc, aes192-cbc, aes256-cbc, blowfish-cbc, cast128-cbc, 3des-cbc
DEBUG:paramiko.transport:server encrypt: [email protected], aes128-ctr, aes192-ctr, aes256-ctr, [email protected], [email protected], aes128-cbc, aes192-cbc, aes256-cbc, blowfish-cbc, cast128-cbc, 3des-cbc
DEBUG:paramiko.transport:client mac: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], hmac-sha2-256, hmac-sha2-512, hmac-sha1
DEBUG:paramiko.transport:server mac: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], hmac-sha2-256, hmac-sha2-512, hmac-sha1
DEBUG:paramiko.transport:client compress: none, [email protected]
DEBUG:paramiko.transport:server compress: none, [email protected]
DEBUG:paramiko.transport:client lang: <none>
DEBUG:paramiko.transport:server lang: <none>
DEBUG:paramiko.transport:kex follows: False
DEBUG:paramiko.transport:=== Key exchange agreements ===
DEBUG:paramiko.transport:Kex: [email protected]
DEBUG:paramiko.transport:HostKey: ssh-ed25519
DEBUG:paramiko.transport:Cipher: aes128-ctr
DEBUG:paramiko.transport:MAC: hmac-sha2-256
DEBUG:paramiko.transport:Compression: none
DEBUG:paramiko.transport:=== End of kex handshake ===
DEBUG:paramiko.transport:kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Got EXT_INFO: {'server-sig-algs': b'rsa-sha2-256,rsa-sha2-512'}
DEBUG:paramiko.transport:Adding ssh-ed25519 host key for <redacted>: b'b4c8c90d11ba08dc8243bb8312554ad6'
DEBUG:paramiko.transport:Trying discovered key b'fc9db78e21554336dba204b193502cde' in /Users/<redacted>/.ssh/id_rsa
DEBUG:paramiko.transport:Adding public certificate /Users/<redacted>/.ssh/id_rsa-cert.pub
DEBUG:paramiko.transport:userauth is OK
DEBUG:paramiko.transport:Finalizing pubkey algorithm for key of type '[email protected]'
DEBUG:paramiko.transport:Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
DEBUG:paramiko.transport:Server-side algorithm list: ['rsa-sha2-256', 'rsa-sha2-512']
DEBUG:paramiko.transport:Agreed upon 'rsa-sha2-512' pubkey algorithm
INFO:paramiko.transport:Authentication (publickey) failed.
DEBUG:paramiko.transport:Trying discovered key b'f7b9889d1f44f0058ded06fa8bd4befa' in /Users/<redacted>/.ssh/id_rsa
ERROR:nornir.core.task:Host 'devdsk': task 'netmiko_file_transfer' failed with traceback:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir/core/task.py", line 99, in start
r = self.task(self, **self.params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir_netmiko/tasks/netmiko_file_transfer.py", line 24, in netmiko_file_transfer
net_connect = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir/core/inventory.py", line 494, in get_connection
self.open_connection(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir/core/inventory.py", line 546, in open_connection
conn_obj.open(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir_netmiko/connections/netmiko.py", line 59, in open
connection = ConnectHandler(**parameters)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/ssh_dispatcher.py", line 344, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/base_connection.py", line 434, in __init__
self._open()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/base_connection.py", line 439, in _open
self.establish_connection()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/base_connection.py", line 1021, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/client.py", line 435, in connect
self._auth(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/client.py", line 678, in _auth
key = self._key_from_filepath(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/client.py", line 598, in _key_from_filepath
key.load_certificate(cert_path)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/pkey.py", line 663, in load_certificate
raise ValueError(err.format(blob.key_type, self.get_name()))
ValueError: PublicBlob type [email protected] incompatible with key type ssh-dss
netmiko_file_transfer***********************************************************
* devdsk ** changed : False ****************************************************
vvvv netmiko_file_transfer ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir/core/task.py", line 99, in start
r = self.task(self, **self.params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir_netmiko/tasks/netmiko_file_transfer.py", line 24, in netmiko_file_transfer
net_connect = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir/core/inventory.py", line 494, in get_connection
self.open_connection(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir/core/inventory.py", line 546, in open_connection
conn_obj.open(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/nornir_netmiko/connections/netmiko.py", line 59, in open
connection = ConnectHandler(**parameters)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/ssh_dispatcher.py", line 344, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/base_connection.py", line 434, in __init__
self._open()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/base_connection.py", line 439, in _open
self.establish_connection()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/netmiko/base_connection.py", line 1021, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/client.py", line 435, in connect
self._auth(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/client.py", line 678, in _auth
key = self._key_from_filepath(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/client.py", line 598, in _key_from_filepath
key.load_certificate(cert_path)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/paramiko/pkey.py", line 663, in load_certificate
raise ValueError(err.format(blob.key_type, self.get_name()))
ValueError: PublicBlob type [email protected] incompatible with key type ssh-dss
^^^^ END netmiko_file_transfer ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Downgrading to paramiko 2.8.1 Works
Name: paramiko
Version: 2.8.1
Summary: SSH2 protocol library
Home-page: https://paramiko.org
Author: Jeff Forcier
Author-email: [email protected]
License: LGPL
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: pynacl, bcrypt, cryptography
Required-by: scp, netmiko
INFO:nornir.core:Running task 'netmiko_file_transfer' with args {'source_file': './test_sbc_cert_file.pem', 'dest_file': '/tmp/test_sbc_cert_file.pem'} on 1 hosts
DEBUG:nornir.core.task:Host 'devdsk': running task 'netmiko_file_transfer'
DEBUG:paramiko.transport:starting thread (client mode): 0x10b12950
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.8.1
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_7.4
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_7.4)
DEBUG:paramiko.transport:kex algos:['curve25519-sha256', '[email protected]', 'ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-group-exchange-sha256', 'diffie-hellman-group16-sha512', 'diffie-hellman-group18-sha512', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha256', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'rsa-sha2-512', 'rsa-sha2-256', 'ecdsa-sha2-nistp256', 'ssh-ed25519'] client encrypt:['[email protected]', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr', '[email protected]', '[email protected]', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc', 'blowfish-cbc', 'cast128-cbc', '3des-cbc'] server encrypt:['[email protected]', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr', '[email protected]', '[email protected]', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc', 'blowfish-cbc', 'cast128-cbc', '3des-cbc'] client mac:['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1'] server mac:['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1'] client compress:['none', '[email protected]'] server compress:['none', '[email protected]'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Kex agreed: [email protected]
DEBUG:paramiko.transport:HostKey agreed: ssh-ed25519
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:kex engine KexCurve25519 specified hash_algo <built-in function openssl_sha256>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-ed25519 host key for <redacted>: b'b4c8c90d11ba08dc8243bb8312554ad6'
DEBUG:paramiko.transport:Trying discovered key b'fc9db78e21554336dba204b193502cde' in /Users/<redacted>/.ssh/id_rsa
DEBUG:paramiko.transport:Adding public certificate /Users/<redacted>/.ssh/id_rsa-cert.pub
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Authentication (publickey) successful!
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:Received global request "[email protected]"
DEBUG:paramiko.transport:Rejecting "[email protected]" global request from server.
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
disabled_algorithm as pointed out it in https://docs.paramiko.org/en/stable/api/transport.html does not work for me.
Reacted by Andrew Wason and Gilbert Gilb's
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Pramiko 2.10.3 Does not work with cert authentication[/-][+]Paramiko 2.10.3 Does not work with cert authentication[/+]jun66j5 commentedon Mar 28, 2022
Please provide debug logging and the code when
disabled_algorithmis used.adarsh-chauhan commentedon Mar 28, 2022
@jun66j5 what all you would like me to disable ?
i added following for debug, is there anything else you are looking for
tomoyoirl commentedon Mar 28, 2022
I do not have all the helpful output just this moment but I am experiencing the same problem and this bug report was a godsend; I downgraded to 2.8.1 and things actually just worked
Before (Paramiko 2.9.2)
After
(The differing key is expected; it is generated and signed each run.)
I have not performed further analysis and am surprised that there are fewer messages about the pubkey algorithm negotiation.
jun66j5 commentedon Mar 28, 2022
I think that your usage of
disabled_algorithmsis wrong.Using
disabled_algorithms={'pubkeys': ['rsa-sha2-512', 'rsa-sha2-256']}, the following line is logged:adarsh-chauhan commentedon Mar 28, 2022
@jun66j5 I haven't disabled anything yet, those logs lines were just to make you aware of available of algorithms from the debug output above.
what should i disable?
if I disable
rsa-sha2-512rsa-sha2-256auth will fail since there is nothing common between server and client.jun66j5 commentedon Mar 29, 2022
What? You said: "disabled_algorithm as pointed out it in https://docs.paramiko.org/en/stable/api/transport.html does not work for me.". I think you've tried
disabled_algorithm.adarsh-chauhan commentedon Mar 29, 2022
@jun66j5 sorry for the confusion, the two output of working and non-working are without
disabled_algorithm.if i disable
rsa-sha2-512rsa-sha2-256i get the following error, which is obvious and hence i asked you what should i disable?jun66j5 commentedon Mar 29, 2022
Thanks for the reply. Okay, I understand
disable_algorithmcannot help the issue because OpenSSH 7.4 doesn't advertise ssh-rsa in server-sig-algs.I try to reproduce it with OpenSSH 7.4 on CentOS 7....
jun66j5 commentedon Mar 30, 2022
Reproduced the issue. The publickey authentication with RSA certificates signed key OpenSSH 8.4 works fine, however OepnSSH 7.4 doesn't work.
OpenSSH 7.4 says while testing with signed key:
I found the following note in OpenSSH 7.8 release notes:
It doesn't work with OpenSSH 7.7 or early probably.
bskinn commentedon Mar 30, 2022
@jun66j5 Do you think there's any sort of fix to be done here? Or is this broken from the OpenSSH side?
jun66j5 commentedon Mar 31, 2022
OpenSSH client uses different signature based on remote server version.
OpenSSH 7.4
OpenSSH 8.4
If paramiko does the same behavior, the following patch will fix the issue.
[-]Paramiko 2.10.3 Does not work with cert authentication[/-][+]SHA2 support broke SHA1 support when server is OpenSSH <7.8[/+]bitprophet commentedon May 13, 2022
Digging into this now:
SSH_BUG_SIGTYPE) as "server-sig-algs are ignored when the RSA key in question is a cert and the server is 7.7 or below"SSH_BUG_SIGTYPE74, meanwhile, is specific to version 7.4, and says "pretend that 7.4 servers sent us a server-sig-algs containing just RSA-SHA2 options, when looking at RSA keys".Looking at solutions (ideally minimalistic ones as this stuff is real sensitive and already a bit rocky):
elsecase in the body of the function (which is kinda the legacy behavior, i.e. why downgrading to Paramiko 2.8 "works" in these cases).ifdo the server version test, making it "did server send server-sig-algs, and can it be trusted (is above 7.7)?"disabled_algorithmsto filter out sha2, as noted upthread.SSH_BUG_SIGTYPE74?)bitprophet commentedon May 13, 2022
I've successfully reproduced the issue on my end using Ubuntu BIonic container w/ OpenSSH 7.6 and an RSA-type key+cert.
Positive test that I at least vaguely grok certs, eg with OpenSSH 8.8 client on my dev host:
And using Fabric plus latest Paramiko main branch, we see the issue (mostly) as reported:
Not a perfect match (server is offering more than just SHA2 here) but enough for me to start testing fixes.
bitprophet commentedon May 13, 2022
FTR the "trying a DSS key" is just due to "falling through" the RSA phase of things, and DSS happens to be next in the client class' list of what to try. It's all horrible crap from the 2000s, see #387 for making that less confusing. Here, it's not relevant, we are trying to make this RSA key work and any failure is still "a failure".
bitprophet commentedon May 13, 2022
Interestingly I can't exactly repro this re: @adarsh-chauhan's "no agreed-upon algos" case where his server is sending back a server-sig-algs of just the two rsa-sha2 types. My 7.6 server always sends back the full list (ed25519, both flavors of rsa, dss, ecdsa) regardless, which then leads to Paramiko either failing like in the first case (if we do not disable rsa-sha2) or succeeding (if we do disable rsa-sha2).
Gonna see if this is some diff between 7.6 and 7.4 but reading the C code doesn't explain it. EDIT: nope, same thing there. Wondering what Adarsh's target server is here exactly - is it something customized to only return the SHA2 family? (EDIT 2: ah, maybe that's vanilla openssh, and Debian is patching theirs, probably with some fix for this...)
FTR my testing (for 7.4) is using:
where that sshd_config is the vanilla deb/ubuntu one (ie almost entirely comments) with this at the end:
and yet:
Per the code, the key/algo settings are actually semi irrelevant, since the EXT_INFO code in OpenSSH doesn't even reference them - it's entirely a hardcoded struct.
bitprophet commentedon May 14, 2022
Backing up a bit, that's a little bit of a red herring: Jun's fix should fit either version of this problem correctly ("make sure we only offer ssh-rsa signature algorithm for RSA certs to OpenSSH 7.7 or older - never rsa-sha2") so I'm just gonna go with that despite it not flowing as nicely as I'd like.
My hope also is that we'll eventually drop SHA1 entirely and that will simplify a large amount of this code!
bitprophet commentedon May 14, 2022
Confirmed that Jun's patch works vs 7.4-debian (once I alter my sshd_config to allow the ssh-rsa cert auth type) and irrespective of whether one is disabling sha2 or not (which makes sense, as that only informs the main logic and not this short-circuit).
bitprophet commentedon May 14, 2022
Working on a test for this now but probably won't finish it tonight 😵 also, this test suite very badly needs some refactoring...but that'll take too long right now 😭
Fix OpenSSH<7.8 + RSA-CERT use re: SHA2
bitprophet commentedon May 17, 2022
Test written, polishing administrivia now but should be out as a 2.9 bugfix (and up) shortly. Thanks all!
backups: Fix issue with verifying SSH hosts with RSA key