Skip to content

Cannot parse OpenSSH 6.5 formatted private keys #602

Closed

Description

@kabel

The key format described at https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key is not currently supported causing key authentication problems when that format is used. The current parser erroneously assumes that the key file is unencrypted.

Related to #387

Activity

  1. mchlt commented on Nov 7, 2015

    @mchlt

    OK, i now have some working code that correctly reads the base64 blobs from a new OPENSSH type key.
    Unfortunately, OpenSSH have chosen a rather exotic key derivation function to derive the key from the passphrase: bcrypt_pbkdf
    The only Python implementation of that that I could find is in py_bcrypt (https://github.com/grnet/python-bcrypt). I'll use that for now to see if I can actually do the decryption.

    Wondering what's paramiko's stance on introducing new module dependencies? I'm thinking maybe do the import in a try..except and then throwing an exception only if someone tries to load an encrypted new format key?

  2. bitprophet commented on Nov 9, 2015

    @bitprophet
    Member

    @mchlt We do the "try/except/complain" for other optional deps right now, such as python-gssapi for GSSAPI support (docs). So we don't want to do it willy-nilly, but there's precedent.

    That said, "a new privkey format used by OpenSSH" feels more mainstream a feature (at least going forwards) than Kerberos/GSSAPI support, so I lean towards "if we can get this implemented before I finish the other work for 2.0, let's put python-bcrypt in that release as a hard dependency".

    If you haven't, you might also look to see if https://github.com/pyca/cryptography has it (this mentions pbkdf2 but I'm not crypto-fluent enough to tell if it's truly the same as python-bcrypt's C-ext) or is willing to add it, since paramiko 2.0 will be relying on cryptography anyways.

  3. bitprophet commented on Nov 9, 2015

    @bitprophet
    Member

    Also, thanks a lot for looking into this! ❤️

  4. bitprophet commented on Apr 25, 2016

    @bitprophet
    Member

    Continuing discussion in here since not 100% sure what'll happen to #618 (it might want closing & replacing with another PR):

    • Support for new OpenSSH 6.5+ private key format  #618 notes that Cryptography doesn't support bcrypt (specifically bcrypt_pbkdf). I'm curious whether @alex / @reaperhulk think it's worth adding to Cryptography at any point? Don't see anything over there implying such, but always nice to ask.
    • Assuming that's not in the works, I'm still reasonably okay with adding the python-bcrypt dependency instead. (TBH, even if Cryptography added it I wouldn't be surprised if they wrapped python-bcrypt itself, so...)
    • In either case, however, Support for new OpenSSH 6.5+ private key format  #618 doesn't merge cleanly with Switched everything to use cryptography instead of pyCrypto #394 which is about to land in master.
      • If @mchlt has time in the very near future to address that (ideally a few days; yes, asking another to get back to me in days when I tend to get back in months, is horrid 😖 ), I can squeeze this into 2.0 as originally planned, and add python-bcrypt as another new install-time dependency.
      • If he doesn't (which would be fine!) I'll put it into the 3.0 bucket, which is basically what 2.0 used to be.
  5. added this to the 2.0 milestone on Apr 25, 2016
  6. reaperhulk commented on Apr 25, 2016

    @reaperhulk
    Contributor

    We'd like to support bcrypt directly, but right now cryptography is (mostly) tied to OpenSSL which doesn't support eksblowfish. We do have pyca/bcrypt, which will shortly be getting wheels for OS X and even linux (via manylinux1, see PEP 513).

  7. bitprophet commented on Apr 25, 2016

    @bitprophet
    Member

    @reaperhulk Huh, neat - I'd still feel better about depending on a PyCA-blessed/implemented bycrypt module vs one that seems to largely be a one-off (not to diss python-bcrypt / py-bcrypt of course, but.) Thanks!

    /cc @mchlt - if pyca/bcrypt serves your needs as well as the other one, maybe switching to it would be something to do while updating.

  8. added this to the milestone on Apr 25, 2016
  9. 13 remaining items

  10. added a commit that references this issue on Jan 7, 2019
  11. hunterirving commented on May 30, 2019

    @hunterirving

    I would also like to see support for this new format.

  12. bitprophet commented on May 31, 2019

    @bitprophet
    Member

    If anyone else has the spare cycles to check up on the years-old assertions I made early in this ticket, re: whether Cryptography has what we need now, that'd be awesome. I'm optimistic that this is possible to do now, if it hasn't already been done in a fork somewhere (looking at @ploxiln whose fork I do not have time to go over in detail yet).

  13. bitprophet commented on May 31, 2019

    @bitprophet
    Member

    Also cc @alex and @reaperhulk as usual on that front ❤️

  14. bitprophet commented on May 31, 2019

    @bitprophet
    Member

    Also VERY briefly skimming my old comments here, I'd put this in 3.0's milestone on assumption that this requires a new dependency (python-bcrypt). In the intervening years I've both relaxed my stance on that topic, and again, Cryptography has gone through a lot of development.

    I'm going to move this into the p1 milestone with those things in mind - I expect we could do this in Paramiko 2.6 or whatever without making anybody too unhappy, even if it does mean a new dependency is added. Folks grabbing new Paramiko minor releases and not doing it for the new key type and being really mad about some new-to-them dependency, seems like it'd be a very small demographic.

  15. modified the milestones: 3.0, p1 on May 31, 2019
  16. ploxiln commented on Jun 1, 2019

    @ploxiln
    Contributor

    the bcrypt dependency was already added in paramiko 2.2.0 for Ed25519 keys - #972

  17. modified the milestones: p1, p0 on Nov 25, 2019
  18. added a commit that references this issue on Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions