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

unhashable type: 'Ed25519Key' #993

Closed
oprypin opened this Issue Jun 13, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@oprypin

oprypin commented Jun 13, 2017

Hi, after updating to Paramiko 2.2.0 some code that previously worked is now broken. I have minimized the reproduction code. Of course, I might have overly minimized it (removed the actual SSH key) because it can't work as is.

import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.load_system_host_keys()
ssh.connect('127.0.0.1')
Traceback (most recent call last):
  File "bis.py", line 6, in <module>
    ssh.connect('127.0.0.1')
  File "/tmp/paramiko/paramiko/client.py", line 377, in connect
    if our_key != server_key:
  File "/tmp/paramiko/paramiko/pkey.py", line 113, in __eq__
    return hash(self) == hash(other)
TypeError: unhashable type: 'Ed25519Key'

known_hosts (fake redacted hash):

127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEZfTeFXnDtkVUYDWL0HiAL8+dXRpxuNpoNsYW1SkpRQ

Bisect:

b395444 is the first bad commit

In older versions this code produces the following error:

paramiko.ssh_exception.SSHException: No authentication methods available
@ploxiln

This comment has been minimized.

Contributor

ploxiln commented Jun 13, 2017

ssh-ed25519 host keys in known_hosts were ignored before. It seems that actually comparing them was not tested.

Thanks for the report!

@oprypin

This comment has been minimized.

oprypin commented Jun 13, 2017

OK, thanks for checking this!
In accordance to what you're saying, it appears that my known_hosts had 2 types of entries and one of them was ignored while the other one worked; now the first one causes a failure.

@bitprophet

This comment has been minimized.

Member

bitprophet commented Jun 13, 2017

That sounds like the most likely explanation, yup; beforehand, I believe the known_hosts parsing would simply have skipped the ed25519 keys entirely (thus getting to your apparent other key for the same host, of a different type like RSA); now it's able to create PKey instances for the ed25519 keys, but they lacked hashability and thus failed the comparison step that came afterwards.

@bitprophet

This comment has been minimized.

Member

bitprophet commented Jun 13, 2017

Let's close this as "closed by PR" and will note in changelog that this was the report, when we merge. Thanks!

@bitprophet bitprophet closed this Jun 13, 2017

ploxiln added a commit to ploxiln/paramiko that referenced this issue Jun 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment