Repository navigation
Conversation
|
Any updates on this one? Are there any plans to get this merged? |
|
Will try and take a look next feature release pass. If you can update it so it merges/works cleanly with master that would help its chances :) thanks! |
|
Also, real-world reproduction steps for testing the functionality would be awesome, I haven't used cert-style authentication much yet. |
|
Hey @bitprophet and @dimrozakis, I'll rebase on master and clean up where required. I have reasonable experience with SSH certs, so I'll provide some extra docs to help introduce the concepts and real-world steps for use. Sometime next week, I hope :) By the way, my requirements for certs+paramiko have been exclusively RSA where paramiko is the client and not server, so this functionality is not included here, but would be awesome if someone with time and expertise could contribute it... just for completeness. |
|
@bitprophet, I've rejigged the PR to merge cleanly with master, added a few tests and some docs (mostly references to people who write about it a lot better than I).
|
|
Thanks @jasonrig! Greatly appreciated. As noted, it's in the next feature release bucket so I'll walk through here when I get to that. |
|
Hey @jasonrig , just returned from holidays, I'm thrilled to see you jumped in and updated the PR, much appreciated! @bitprophet is there any estimation on when the next feature release will come out? |
|
@dimrozakis I'm really bad at estimates so I need to stop giving them! I will note that I tend to work in sprints lately, so the next time I personally need to push out something feature-y I will also go down the milestone list and try to knock out as much as I can. |
|
Adding my support to see this PR merged after two years. We use this kind of signed cert to manage server access across our organization without having to set up individual ssh keys on each server. Facebook engineering recommends this sort of setup to control authorization on large scale production systems: https://code.facebook.com/posts/365787980419535/scalable-and-secure-access-with-ssh/ I expect this use case will become more common! |
4 similar comments
|
@incognick I'm happy to take advice on whether, for example, I would say subsequent improvements beyond this core enhancement should be submitted as additional PRs down the track. However I do not take issue with anyone forking my repo and basing a new branch on this PR with their desired improvements, and submitting their own changes as a new PR. So if you see any room for improvement, please go ahead and implement it! |
|
I'm +1 on merging as-is and figuring out integration with other cert-unaware codebases like Fabric afterwards. Moved this to the 2.3 milestone since it's thematic with some other auth-related features there like smartcard support (#827). (Actually makes me wonder whether that should be made aware of this...thoughts welcome, tho always possible to add later too.) |
|
Successfully tested out OpenSSH-level certificates on my end so I understand that level of things. Also skimmed the RFC. So next up is actual review, manual testing & merging \o/ |
|
As-I-go commentary (I will address most/all while merging):
|
|
@ploxiln I edited that a bunch after you emoji'd it...FYI :D |
|
I see :) It's good that you're investigating and finding the relationship with RSAKey is a bit awkward, and there are some currently unused attributes, sooner rather than later. I clearly didn't do that :) It might be a good idea to open a pull request with your in-progress cleaned-up merges, or just point to your branch, so you might get some eyes and help on it. |
|
Was planning to at least link the branch once it's pushed, yea. Also trying very hard not to overstep bounds here re: overall key class organization stuff...>_> Another random side note: wondering if we want to add 'full' client side support for this in the same way OpenSSH client does; e.g. its
That said - not super worried because we can add that later if folks feel it's missing, and at the moment, one is either explicitly instantiating |
|
Actually, just realized that would solve the possible confusion with Still very unhappy with this fragile constructor logic anyways, so, maybe I'll meet myself halfway and rip it up into multiple constructors. Would serve as an experiment re: the same operation on the |
|
Nah. Much of the annoyance I'm having stems from the original classes too (insofar as they mutate their responsibilities depending on whether they were given private key data or not). This stuff's all due a bigger shakeup later so I will defer to then. Still need to add a bunch more tests around corner cases though. |
|
You might get a decent compromise in the bang-for-the-buck category by being intentionally ignorant about the contents of the certificate blob. On the client side, while the components that make up the certificate are mildly interesting, for use in client authentication, that is left up to the server side to make sense of; the client offers the certificate as a blob, then if the certificate could be used for authentication, it proves possession of the corresponding private key. The client does not even need to unravel the blob itself. This is why the current Paramiko code works just dandy with certificates loaded in a ssh-agent, as long as it can get the blob contents, and sign the composited message, it's all the same on the server side. Getting the details of the certificate content, or even being able to generate new certificates would be nice to have features, but probably pales in comparison to just being able to blindly loading a blob and being able to offer it as an alternative publickey authentication attempt, if available. |
|
In expanding the test suite (and by extension, some functionality/exceptions) I ran into one case that has no immediately obvious answer: what to do if someone instantiates the class with a public-only key alongside the cert? (Provided that it is the "correct" public key; mismatching public key data is covered elsewhere.) It's a little tempting to except here too, because it implies user error:
All that said, it would not technically hurt to be given the pubkey material a 'second time', so it's remotely possible someone is dealing with grandfathered-in kwarg dicts or whatever, and would be unhappy about an exception. Which is why I'm torn - it does not violate correctness. |
|
@radssh That's a good point, and also applies to the comment I posted after yours (didn't see yours til just now.) The public key part, which is embedded in the cert, is all that's necessary for auth as a client; my understanding above is a bit off (just re-read Transport to remind myself; probably adding some comments therein so future-me doesn't make this mistake again), private key is not required when one has a cert. EDIT: hm, no, that can't be right either. Clearly not a good brain day today. It's fine, I'm not supposed to be an expert or anything. My original assertion was right - to successfully auth one does need private key data so one can respond to server's challenge, "prove you have the private half of this certified public key". |
|
Again, I suspect eventually breaking our classes up would also make it harder for high-functioning morons like myself to get tied in knots. Handing "the authentication process" discrete certificate and private key objects, for example, would make it more obvious that the cert largely just replaces the process of distributing a EDIT: On the other hand, from the perspective of the network messages involved (i.e. Still not suggesting we go this route today but food for thought. |
not quite - to be of much use at all, the client needs the private portion to do the signing (prove possession of (unlocked) private portion). Having a cert without the private portion of the key is almost like having the public key (plus a bunch of other publicly viewable/extractable items). Not much you can do with it alone, other than regurgitate it. The cert does contain a form of embedded public key contents, but it requires some minor unraveling to get to (RSA you can get (e,n), DSS (p,q,g,y), but as discrete values, not as a ready-made Message that would fit with Paramiko), so to transform cert -> pubkey can be done, but would need a case by case handling. Generally, since you don't need to open the envelope to pass it along, just need to sign the sealed envelope; why bother with those details. Point is, unless you really "need" the pubkey, you can skip the unraveling completely, and just handle the cert blob, as long as you can submit the whole enchilada (Message with blob, and other bits) + (Private key signed Message) to the remote side to authenticate. It's the remote side that (should) verify not only the signature of the auth request done by "your" private key, but also the unraveled blob, which itself is a signed Message by some CA, presumably identifiable by the server as trusted, according to the CA public key on file on the server side. The worst that can happen on the client side, is that the server declines authentication using the cert, for whatever reason (untrusted CA, malformed signature, validity interval expired, principal name does not match, etc.), and the client has to try another auth method (plain public key) or just cope with the failed authentication. Yes, it would be nice to be able to elegantly detect inconsistencies in advance, but that could be construed as scope creep 😄 |
|
Once again, I edited my comments once I had that same realization (re: private key.) 🙃 |
|
More waffling - realizing that my initial read on the Upshot is that I'm probably just gonna put the constructor args back the way I found them and file it under "let's just reorganize the entire friggin thing in a .0 release". |
|
(At least the docstring is getting a massive workout from all this...and the test suite...) |
|
Noticed another oops, the |
|
Not done but pushing what I have so far today as the 531-int branch. Think this is the correct diff view (had to construct it manually because Github wasn't wanting to show me the original branch despite it still existing on Jason's end...): jasonrig/paramiko@rsacert...paramiko:531-int#files_bucket Can't promise exactly when I will pick this back up again but it shouldn't be more than a few days to a week tops. I intend to finish fleshing the tests out, the hopefully small bits of extra implementation needed to satisfy them (mostly around raising more footgun errors; and I'll be happy to skimp on some of 'em for now) and then merging. |
|
While I was supporting my dayjob, @radssh implemented what I think I'll consider a second draft of this (in #1042), with a different approach that has benefits over the one here:
Obviously I'm not super tickled at the idea of dropping or deferring something both the OP and myself put a bunch of effort into, but given that using certs to authenticate as a client feels like the much more common use case, #1042 serves that better and with less code and so it's more tempting to merge first. |
|
Dropping this from the release milestone and I encourage all followers of this ticket to try out the #1042 functionality when it's released. Keeping this alive for now & hoping anyone who finds the #1042 code lacking can report details on their use cases here. Right now I'm expecting that will chiefly be a) server-side support and b) host-certificate validation support on the client side. |
|
On second thought (and partly because #1042 got expanded during testing & does more now!), going to close this. Any remaining missing functionality can be reported as its own ticket/s. EDIT: to be clear: #1042 has just been merged to master and will be released in the near future. It should serve almost all client-side cert needs as well as limited server-side and sig verification! |
I have extended the RSAKey class to support the [email protected] type of certificate authentication in a new RSACert class. A test case was added to test_pkey.py to test loading an RSA certificate (a signed public key that's the same one given in the tests already).
I think this class should be a reasonable example from which DSS and ECDSA certificate classes can also be created.
Let me know what you think!
Jason