You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problems with using ECDSA known_hosts keys when negotiation also accepts RSA or DSS keys #243
Ubuntu 12.04, paramiko 1.12
I'm trying to connect to a certain host whose only key in the known_hosts file is an ECDSA key, and paramiko is failing saying "server 'other-server' not found in known_hosts"
Investigating into the issue, I added a line to transport.py at line 1792 to print out agreed_keys, and it lists ('ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256').
I tried changing client.py and transport.py to pass in the host keys listed in known_hosts for the given host into the Transport and reduce the set of agreed keys to those listed in known_hosts, but I ran into an SSHException: Invalid key in Transport.start_client.
I'm also suffering from this issue -- since Ubuntu generates and uses ECDSA by default, my known_hosts generally only has ECDSA keys for Ubuntu servers, and so when Paramiko gets RSA keys from the server, it can't find them in known_hosts and bails.
For reference, to fetch the remote's RSA key and add it to your known_hosts, you can...
Also seeing reports similar to this in #350 which I'm merging into this one. Copying labels + adding high priority since this feels like a widespread problem :(
changed the title [-]Problems with using ECDSA keys when negotiation also accepts RSA or DSS keys[/-][+]Problems with using ECDSA known_hosts keys when negotiation also accepts RSA or DSS keys[/+]on Sep 6, 2014
I'm able to recreate this with an Ubuntu 13.10 VM known locally as ubuntu by doing the following:
Use regular ssh to connect; this adds (via 'ask' method) the RSA key to my personal known_hosts by default.
Use ssh-keyscan -t ecdsa localhost (NOTE: notersa-keyscan as mentioned in Host Key Type Selection Should Match OpenSSH's #350. Assuming that was a typo?) on the VM to obtain its ECDSA key; copy that by hand into known_hosts on localhost.
Use Fabric as the driver, via fab -r -H ubuntu -- whoami (-r turns off an implicit Fabric-level triggering of Paramiko's auto-add-keys policy) for a simple sanity connection test.
With both keys enabled, it works fine.
With the RSA key commented out, it complains about not finding the host in known_hosts, as reported.
Confirmed that the bug exists all the way from Paramiko 1.12 (first ECDSA release) through latest pre-1.15 master.
Now looking through the code but the issue outlined in #350 sounds like the culprit - Transport is just too naive about deciding which key to seek out. (This is probably Yet Another Example of #387.)
Tried writing a test for this but once I got things working 'correctly' (vs having more fun #387 related key errors) the test actually passes without changes, meaning I probably need to do more work to ensure the test triggers the same code path having problems here (re: known_hosts).
This is holding up release of 1.15 and also feels like the right fix may be tied up with the bigger changes needed for #387, so I am punting for now :(
Similar issue here. client.load_system_host_keys() loads nothing from ~/.ssh/known_hosts. paramiko 1.15.2 on arch linux platfrom. Some entries in ~/.ssh/known_hosts:
FYI: For me, issue was a problem on Ubuntu 14 LTS apt-get package of paramiko ... But by simply by patching the one line in transport.py (as mentioned in another related isue to this one) to change the order of the keys... Then it works fine
We had this problem with version 2.1.1 of paramiko (installed by a 3rd-party library) and, searching for a solution, we stumbled on this issue.
Not sure what to do, we upgraded to the latest version (pip install paramiko==2.4.2) and the problem appears to have been resolved. The cause of the fault may be very different but moving to the latest release fixed it for us.
Activity
adamgreig commentedon Mar 21, 2014
I'm also suffering from this issue -- since Ubuntu generates and uses ECDSA by default, my known_hosts generally only has ECDSA keys for Ubuntu servers, and so when Paramiko gets RSA keys from the server, it can't find them in known_hosts and bails.
For reference, to fetch the remote's RSA key and add it to your known_hosts, you can...
bitprophet commentedon Mar 22, 2014
This might be fixed by #218, currently too tired to tell offhand XD but want the link to be created so I or someone else checks...
nikicat commentedon Aug 29, 2014
@bitprophet as I can see #218 doesn't help
bitprophet commentedon Sep 3, 2014
OK, thanks @nikicat.
Also seeing reports similar to this in #350 which I'm merging into this one. Copying labels + adding high priority since this feels like a widespread problem :(
[-]Problems with using ECDSA keys when negotiation also accepts RSA or DSS keys[/-][+]Problems with using ECDSA known_hosts keys when negotiation also accepts RSA or DSS keys[/+]bitprophet commentedon Sep 9, 2014
I'm able to recreate this with an Ubuntu 13.10 VM known locally as
ubuntuby doing the following:sshto connect; this adds (via 'ask' method) the RSA key to my personalknown_hostsby default.ssh-keyscan -t ecdsa localhost(NOTE: notersa-keyscanas mentioned in Host Key Type Selection Should Match OpenSSH's #350. Assuming that was a typo?) on the VM to obtain its ECDSA key; copy that by hand intoknown_hostson localhost.fab -r -H ubuntu -- whoami(-rturns off an implicit Fabric-level triggering of Paramiko's auto-add-keys policy) for a simple sanity connection test.known_hosts, as reported.Confirmed that the bug exists all the way from Paramiko 1.12 (first ECDSA release) through latest pre-1.15 master.
Now looking through the code but the issue outlined in #350 sounds like the culprit -
Transportis just too naive about deciding which key to seek out. (This is probably Yet Another Example of #387.)bitprophet commentedon Sep 10, 2014
Tried writing a test for this but once I got things working 'correctly' (vs having more fun #387 related key errors) the test actually passes without changes, meaning I probably need to do more work to ensure the test triggers the same code path having problems here (re: known_hosts).
This is holding up release of 1.15 and also feels like the right fix may be tied up with the bigger changes needed for #387, so I am punting for now :(
pierreozoux commentedon Mar 6, 2015
I'm hitting similar issue 👍
kawing-chiu commentedon Mar 9, 2015
Similar issue here.
client.load_system_host_keys()loads nothing from~/.ssh/known_hosts. paramiko 1.15.2 on arch linux platfrom. Some entries in~/.ssh/known_hosts:bitshark commentedon Mar 26, 2015
FYI: For me, issue was a problem on Ubuntu 14 LTS apt-get package of paramiko ... But by simply by patching the one line in transport.py (as mentioned in another related isue to this one) to change the order of the keys... Then it works fine
goshlanguage commentedon Apr 2, 2015
I'm having this issue tried to connect to a Centos 7 vm to a keyed user.
bitprophet commentedon May 23, 2015
#473 seems possibly related to this
alanbchristie commentedon Feb 25, 2019
We had this problem with version
2.1.1of paramiko (installed by a 3rd-party library) and, searching for a solution, we stumbled on this issue.Not sure what to do, we upgraded to the latest version (
pip install paramiko==2.4.2) and the problem appears to have been resolved. The cause of the fault may be very different but moving to the latest release fixed it for us.ploxiln commentedon Feb 25, 2019
This fix landed in 2.1.3: #910