New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing error message when trying to verify unknown host key types #67
Comments
I had this error: I can connect from the shell, but paramiko says "Unknown server workdevel114". There were two similar entries in known_hosts: user@host> grep workdevel114 ~/.ssh/known_hosts The seconds entry (|1|....) seems to confuse paramiko. I get: Unknown server workdevel114 Version: paraiko-version: 1.7.7.1-1ubuntu1 |
Renamed ticket to be more obvious. There's two problems here:
I haven't traced this all the way yet but I think this section of Transport is linked. My untested guess so far is:
@CiaranG if you can provide a foolproof way to recreate this, that will help me test any fixes. My guess is you've got ECDSA host keys from an Ubuntu 12.04 (or 12.10?) server running a newer OpenSSH, stored into your known_hosts via using the normal |
This may also be related to #87 since it also deals with the |
@bitprophet thank you for looking at this. Tell me I can help. |
I can't say I know exactly the situation that @CiaranG was facing, but I can say that I encountered a situation that sounds like this one, and it doesn't match the description that @bitprophet describes above. I'm running Ubuntu 12.10 and I just installed paramiko 1.10.0 using pip. I'm trying to connect to localhost using paramiko. Here's the output when I set logging to DEBUG.
In fact, it seems like it's negotiating the host key process correctly, because that is the correct fingerprint for my host RSA key:
It was still pretty surprising to me, though, because I told paramiko to load my
So it definitely seems to be loading the keys in my known_hosts file. And those keys seem to be correct because I don't have any trouble SSH'ing in normally:
Fortunately, though, I know that the key for localhost is the last one added to my known_hosts file, since I just accepted the key earlier today. The entry says:
Indeed, although there are a bunch of ecdsa-sha2-nistp256 keys in this file, none seem to show up in the HostKeys output above. So it seems like paramiko is silently ignoring ECDSA keys when they're being read in the known_hosts file, and getting the RSA key from the server, which isn't in my known_hosts file, and therefore complaining that the key is unknown. Based on this analysis, I don't think this bug merits any fix more complicated than emitting a message of level WARNING when we encounter a key of a type that we're not familiar with (line Line 81 in 01aaf70
|
@glasserc Thanks for the detailed notes & the related pull requests! Your situation does still feel strongly related, though I do wonder why you and the OP appear to differ re: the host keys offered by the target host and/or stored in known_hosts. |
Between the newer PR from @glasserc and the existing PRs for ECDSA support & other fixes, I think this guy is now redundant; closing. |
Hello, I encountered this issue and wanted to post a workaround here. The issue was indeed the ssh server sending ecdsa keys. On my debian Wheezy system I disabled ecdsa by commenting out a single line in /etc/ssh/sshd_config: HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_ecdsa_keyRestarted sshd, and it was back to using RSA. There were some ecdsa keys in my known_hosts file so I just deleted it to reset, and logged in manually to recreate the keys. From there, paramiko worked perfectly as expected, with RSA host key checking. |
I've encountered a user report of paramiko's load and save methods not being able to write a ecdsa-sha2-nistp256 back to a known host file in python-paramiko 1.7.7.1-3 Can you let me know if you think that version should be able to load/use and save that key back successfully? |
I upgraded a machine and the machine changed keys as well as enabled ECDSA. I copied the machine's
Yes, paramiko first fails to negotiate the ECDSA connection, but then falls back to RSA. I do not mind doing this manually as I would much rather get the key manually than auto-accept.
|
@mpdehaan - yes, 1.7.7 is too old and unsupported now, you'll need 1.13+ for ecdsa support to function, sorry! @Tatsh there's a few open tickets about interplay between multiple key types, I think your issue probably falls under one of them. Please keep an eye out for upcoming bugfix/feature releases and see if they help. If not, please open a new ticket & link to your comment in this one. Thanks! |
Just wanted to chime in and say that I'm seeing the issue with ECDSA keys as well and that @zeugmatis workaround is still valid. |
Oh good makes me happy to have helped someone - thanks for that! :-) Mark On Dec 16, 2014, at 3:35 AM, Robin notifications@github.com wrote:
|
I'm trying to connect to a brand-new EC2 instance with a ECDSA key, and the connection fails after the messages about the ECDSA keys. INFO:paramiko.hostkeys:Unable to handle key of type ssh-ed25519 |
Those seem unrelated to me, @benson-basis - the hostkeys errors are Paramiko trying to load your local host-keys database and being unable to parse some of the host keys; the 'Connection refused' error should be a straight up "that port is literally not talking to me" error. If the problem was in the actual host-key exchange, you'd be getting SSHErrors or similar from Paramiko itself, not ConnectionRefusedError. My guess is your code is trying to talk to the EC2 instance before its sshd is operational. (If this specific host is one of the ones with the ed25519 keys, though, you would then receive actual SSH level errors...) |
Yea, I'm sorry. I got turned around in my early debugging process. All is well @bitprophet . |
Paramiko only recognises ssh-rsa and ssh-dss keys when reading known_hosts. However, newer versions of openssh use additional key types which Paramiko silently ignores, resulting in very confusing missing host key errors which occur when attempting to connect with Paramiko, even though the same connection via the command line ssh works perfectly.
From the openssh documentation:
The text was updated successfully, but these errors were encountered: