Skip to content

prefer ecdsa host key types - #911

Closed
ploxiln wants to merge 2 commits into
paramiko:2.0from
ploxiln:ecdsa_more_support
Closed

ploxiln wants to merge 2 commits into
paramiko:2.0from
ploxiln:ecdsa_more_support

Conversation

@ploxiln

@ploxiln ploxiln commented Feb 23, 2017

Copy link
Copy Markdown
Contributor

fixes #794 and #900

second part of an alternative set of PRs to #899

@coveralls

coveralls commented Feb 23, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.05%) to 74.227% when pulling 1186105 on ploxiln:ecdsa_more_support into 5061ee6 on paramiko:master.

@ploxiln

ploxiln commented Jun 2, 2017

Copy link
Copy Markdown
Contributor Author

rebased, conflicts resolved

@ploxiln
ploxiln force-pushed the ecdsa_more_support branch from df024e5 to 25771e9 Compare June 5, 2017 05:48
@ploxiln

ploxiln commented Jun 5, 2017

Copy link
Copy Markdown
Contributor Author

I decided to change the style of this, and use the literal key type names.

There's only the three ECDSA key types, and that set won't change any time soon, so the balance of simplicity/robustness in this case favors just writing them out, in my humble opinion. I haven't seen an opinion either way from the maintainer, and I would be happy to change the style back if that ends up being preferred.

For reference, here's the previous version of this PR, which I thought was uglier and not really justified by the theoretical robustness:

--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -122,10 +122,10 @@ class Transport (threading.Thread, ClosingContextManager):
         'hmac-md5-96',
         'hmac-sha1',
     )
-    _preferred_keys = (
+    _preferred_keys = tuple(ECDSAKey.supported_key_format_identifiers()) + (
         'ssh-rsa',
         'ssh-dss',
-    ) + tuple(ECDSAKey.supported_key_format_identifiers())
+    )
     _preferred_kex = (
         'diffie-hellman-group1-sha1',
         'diffie-hellman-group14-sha1',
@@ -210,8 +210,11 @@ class Transport (threading.Thread, ClosingContextManager):
     _key_info = {
         'ssh-rsa': RSAKey,
         'ssh-dss': DSSKey,
-        'ecdsa-sha2-nistp256': ECDSAKey,
     }
+    _key_info.update(
+        (name, ECDSAKey)
+        for name in ECDSAKey.supported_key_format_identifiers()
+    )
 
     _kex_info = {
         'diffie-hellman-group1-sha1': KexGroup1,

You can see the new version by looking at this PR's Files Changed

@ploxiln ploxiln changed the title more ecdsa host key support prefer ecdsa host key types Jun 5, 2017
@ploxiln
ploxiln force-pushed the ecdsa_more_support branch from 25771e9 to b4d97b3 Compare June 5, 2017 08:37
@ploxiln

ploxiln commented Jun 5, 2017

Copy link
Copy Markdown
Contributor Author

... and then I split out half of this PR to #981 because it really is a bug fix that should be backported

@bitprophet

Copy link
Copy Markdown
Member

Had a second thought about "won't this bite anyone currently relying on the selection of the older key types, and thus shouldn't this be a 3.0 change", but that's more of a worry for user keys and not host keys, I think.

@ploxiln
ploxiln force-pushed the ecdsa_more_support branch from b4d97b3 to 674fd06 Compare June 6, 2017 02:14
@ploxiln

ploxiln commented Jun 6, 2017 •

Copy link
Copy Markdown
Contributor Author

resolved conflicts, put ecdsa keys even in front of ed25519, because this is the order openssh on macOS seems to use:

debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa,ssh-dss

EDIT: preference of more recent openssh on ubuntu-16.04 is similar:

debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa

@bitprophet

Copy link
Copy Markdown
Member

Seems reasonable. thanks!

@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

re: selection of keys: that's what #910 is about, often the wrong host key is selected ...

@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

... to clarify: and then after the wrong host key is selected, connection is silently allowed to continue under a MissingHostKeyPolicy variant which doesn't save. This happens for fabric and I think ansible as well

@bitprophet

Copy link
Copy Markdown
Member

Seems #981 also needs the ed25519 related change, I am merging that now so I will take care of it.

Sounds like #910 is additive on top of these changes so I'll get to it when I get to it (it is open...I am trying to see how much of the 2.2 milestone I can chow down on for an actual 2.2 tonight)

@bitprophet

bitprophet commented Jun 6, 2017 •

Copy link
Copy Markdown
Member

Mildly amusing thought, shouldn't OpenSSH (and us) be preferring the larger-key-size variants of these algorithms over the smaller-key-size ones? (I.e. ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256, so that the largest one supported by the host wins out.)

I kinda trust OpenSSH knows what it's doing so as always "do what they do" seems fine, but it made me think. Also presumably there's a cost to using larger keys.

@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

The reasoning might be that the larger key sizes are needlessly/wastefully large for today, but available in case of need in the future.

@bitprophet

Copy link
Copy Markdown
Member

Honestly, if this is backwards compatible & also just not very instability-causing, we might as well roll it back to 2.0 and treat it as an outright bugfix. Otherwise feels a little odd putting this in 2.2 but not 2.0.x/2.1.x. Can always revert it in those lines if somebody gets megafucked somehow.

@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

Agree it should probably be in 2.0 as well, but the conflict resolution when up-merging to 2.1 will be a bit tricky. I do have a branch with this change applied to 2.0 already, I'll push it up ...

@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

oh nvm I was thinking about #910 again

The openssh client prefers ecdsa server host keys.
@ploxiln
ploxiln force-pushed the ecdsa_more_support branch from 674fd06 to bace976 Compare June 6, 2017 03:09
@ploxiln
ploxiln changed the base branch from master to 2.0 June 6, 2017 03:09
@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

rebased on 2.0 branch

@bitprophet

Copy link
Copy Markdown
Member

Ugh I thought I said I was in the middle of doing that, but, I did not say that. Sorry! Got hung up pushing it because of a stupid docs related rabbit hole.

@bitprophet bitprophet closed this in 691f619 Jun 6, 2017
@bitprophet

Copy link
Copy Markdown
Member

Pushed now, includes a newer changelog line. Thanks again.

@ploxiln

ploxiln commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

no problem, thank you :)

@ploxiln
ploxiln deleted the ecdsa_more_support branch September 13, 2017 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants