Skip to content

auth_handler rejects 384-bit and 521-bit ECDSA key #902

Closed

Description

@jun66j5

I get the following error when publickey auth with 384-bit ECDSA key to paramiko server. However, 256-bit ECDSA key works fine.

2017-02-22 02:34:24,877 [12915] INFO: Auth rejected (none).
2017-02-22 02:34:24,884 [12915] INFO: Auth rejected: unsupported or mangled public key

It seems Transport._key_info has only ecdsa-sha2-nistp256.

diff --git a/paramiko/transport.py b/paramiko/transport.py
index c4f0ca7c6..bfd22b637 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -207,8 +207,9 @@ class Transport (threading.Thread, ClosingContextManager):
     _key_info = {
         'ssh-rsa': RSAKey,
         'ssh-dss': DSSKey,
-        'ecdsa-sha2-nistp256': ECDSAKey,
     }
+    _key_info.update(map(lambda id_: (id_, ECDSAKey),
+                         ECDSAKey.supported_key_format_identifiers()))

     _kex_info = {
         'diffie-hellman-group1-sha1': KexGroup1,

After the patch, it works well.

And, it's difficult to investigate because an exception isn't logged when the error occurs. I consider the exception should be logged.

diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py
index cab27a884..6486935ae 100644
--- a/paramiko/auth_handler.py
+++ b/paramiko/auth_handler.py
@@ -416,8 +416,9 @@ class AuthHandler (object):
             except SSHException as e:
                 self.transport._log(INFO, 'Auth rejected: public key: %s' % str(e))
                 key = None
-            except:
-                self.transport._log(INFO, 'Auth rejected: unsupported or mangled public key')
+            except Exception as e:
+                self.transport._log(INFO, 'Auth rejected: unsupported or mangled public key (%s: %s)',
+                                    e.__class__.__name__, e)
                 key = None
             if key is None:
                 self._disconnect_no_more_auth()

After this, I investigated the issue by the following log.

2017-02-22 02:43:00,367 [12253] INFO: Auth rejected: unsupported or mangled public key (KeyError: u'ecdsa
-sha2-nistp384')

Activity

  1. ploxiln commented on Feb 21, 2017

    @ploxiln
    Contributor

    dup of #794 though with potentially better proposed fix

  2. jun66j5 commented on Feb 21, 2017

    @jun66j5
    ContributorAuthor

    Oh, sorry. I've searched the same issue but missed it.

  3. ploxiln commented on Feb 22, 2017

    @ploxiln
    Contributor

    I mean, I think the fixes proposed here are good stuff, no need to apologize :)
    I've borrowed them in #899

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions