You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement support for ControlMaster / ControlPath / etc #852
No, AFAIK there's no support for this out of the box.
It's actually something I personally could use at my current job so I was planning to give it a whack sometime soon-ish. Thanks for making the ticket for me :)
changed the title [-]Can we have paramiko respect the ControlMaster/ControlPersist options?[/-][+]Implement support for ControlMaster / ControlPath / etc[/+]on Nov 29, 2016
My own vague recollection is that it works by opening a Unix socket to the given host and then leaving that socket on-disk for some period of time, to be reused as a transport socket by subsequent connections. No idea how the authentication is preserved or how the persistence is impemented (assuming timestamp of some kind + a check on attempted reuse of the channel, which fails if it's "too old".)
Many people in open source would rather spend time actually working on projects (or heaven forbid, anything but open source) rather than triaging the hundreds of notifications you receive daily. Please be respectful to everyone's time. If the issue is really pertinent, you might take a first stab at a PR, even if it's not complete, just to generate discussion and possibly bring in others to help tackle this issue.
We're all in this together. :)
Reacted by Ruslan Kuprieiev, Takuma Yoneda, iczero and iBug
Reacted by Samuel Reed, Marc Aymerich, Gaëtan Trellu, Josh Heinrichs, Ruslan Kuprieiev, Jeremy Lowery, Seth Larson, iczero, Elliot Fontaine, Cassandre and 2 more
You can browse the issue and pull request activity of this project yourself. If you do, you will see that there is no progress being made on this feature. Asking periodically only results in "noise". The fastest way for you to get this feature in paramiko would most likely be for you to implement it yourself.
heyo! Any recent discussion or updates for this issue? I was so excited to find paramiko but missing this functionality is going to make it not an option for the tool I'm developing (very sad!)
This thread has a couple of jumps to other issues and PRs - just wanted to link to (what I think is) the most recent / up to date and say I would really like to see this merged!
I may have missed it in the various comments but I had to remember how to use ControlMaster and grok things enough to realize that this does still omit the initialization of the socket, so recording exactly what I've done here for posterity. Or in case I don't merge it today, as I'm still hesitant (see below).
Initialization using OpenSSH (8.6) - could use -n or whatever I guess, meh:
This leaves control.sock around. In reality one would use ControlPath=/tmp/my-box-o-sockets/%C or similar... (also, I did just merge support for that token in config file parsing...)
Fabric snippet to use that socket and this PR:
import logging; logging.basicConfig(level=logging.DEBUG)
from fabric import Connection
c = Connection('hostname', connect_kwargs=dict(controlpath='control.sock'))
c.run('whoami')
Invoking it show this on the client side (along with all the invoke/fabric level bits):
DEBUG:paramiko.transport:Connected to ControlPath 'control.sock'
DEBUG:paramiko.transport:Connected to SSH ControlMaster (PID 47821)
DEBUG:paramiko.transport:starting thread (client mode): 0x7e62bf28
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
jforcier
DEBUG:paramiko.transport:[chan 0] EOF received (0)
DEBUG:paramiko.transport:[chan 0] Unhandled channel request "[email protected]"
DEBUG:paramiko.transport:[chan 0] EOF sent (0)
and in the other terminal which had its stdout/err linked to the controlmaster process, we see the OpenSSH debug out:
So as advertised and noted by a bunch of folks, yay! It kinda works.
Unfortunately it still has a lot of drawbacks:
Requires local ssh client to stand up the control process/socket, as noted. I'm honestly surprised folks are okay with this but I guess using Python for all the heavy lifting is still a big win over a bunch of shelling out to ssh to run stuff 😁
I did see the notes in one of the other tickets about how this is doable, just (a bunch) more work
Multiple reports of it having various places where it falls down - I see that key renegotiation may have been fixed at least, but still a bit worried this will be a 60% solution, maybe an 80% solution, but not a 95/99/100% one, even within that limited use case of "something else manages the socket".
As noted elsewhere, the code organization is still slightly kludgy - it might want a different classmethod constructor or similar, there's a number of spots where there need to be if/else statements for very core protocol things. Not a dealbreaker by itself but it sets off my "here there be bugs" alarm and certainly makes things harder to read/maintain.
Counterpoint, it's not like there are other obvious BETTER ways to integrate it without serious refactoring of Transport/Packetizer/etc. Which would be lovely - Paramiko is ancient and crufty and not how I personally would have architected a lot of this - but it's quite a task. So maybe this is just the best way to add mux support for now.
I'm torn between "merge it for folks who need the base-case that does work" and "we will get TONS of people assuming this is fully-baked ControlMaster support and filing endless tickets about its shortcomings".
Might be able to have our cake and eat it too by pursuing that "different constructor" idea - so that it's not quite so obvious a "new feature" but a clearly marked "if you use this, you are off-roading until we pave it". Still means all those small code branches are there to possibly trip up regular users if there's bugs, but hopefully not.
For now I'm not going to merge this for 2.10 but I'll try to tidy up the related tickets and get all still-interested eyes in here for more discussion, and have myself more of a think, and perhaps we can add this experimentally in the next feature release. Having "experimental features" is something I should probably figure out anyways - it would give tickets like this a pressure release with, arguably, a fig leaf that I can wave at people who try whining about how it doesn't work.
Reacted by Thomas Kluyver, aviadfiant, valley3405, Neoma Fong, ghost-ng, Darnin and Fabrice Normandin
@bitprophet - tracking the back and forth here and last note I see here is a potential for release, just want to follow up and/or make sure i'm looking in the right place for the version that includes this feature. cheers!
@unkn0wnsyst3m a) yes, following this ticket is the best way to tell whether it's been merged/released/made redundant (the line item I left about code org / constructors, for example, may tie into work I'm about to start re #387), and b) I'm afraid I don't accept feature-specific bounties at this time (though I appreciate the offer!).
Please rest assured that this is still a ways up my priority list (mostly under the "we should strive to match OpenSSH features when we can" header), it's just not at the very top yet.
Reacted by ghost-ng, Zack Polizzi, Santtu Sievänen, Fabrice Normandin and Anderson de Andrade
Activity
bitprophet commentedon Nov 29, 2016
No, AFAIK there's no support for this out of the box.
It's actually something I personally could use at my current job so I was planning to give it a whack sometime soon-ish. Thanks for making the ticket for me :)
[-]Can we have paramiko respect the ControlMaster/ControlPersist options?[/-][+]Implement support for ControlMaster / ControlPath / etc[/+]bitprophet commentedon Nov 29, 2016
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.mux?annotate=HEAD may be a good spot for me to start here. Haven't actually read it yet.
My own vague recollection is that it works by opening a Unix socket to the given host and then leaving that socket on-disk for some period of time, to be reused as a transport socket by subsequent connections. No idea how the authentication is preserved or how the persistence is impemented (assuming timestamp of some kind + a check on attempted reuse of the channel, which fails if it's "too old".)
bitprophet commentedon Nov 29, 2016
Also, for search result purposes, noting that this feature is often referred to as 'multiplexing'.
omani commentedon Dec 23, 2016
hi @bitprophet,
just wanted to know if you have any news regarding this feature?
omani commentedon Mar 9, 2017
@bitprophet, any news?
omani commentedon Apr 6, 2017
@bitprophet,
what is the status of this issue?
bitprophet commentedon Apr 6, 2017
Dude, asking over and over won't make me magically find more time! Sorry :(
omani commentedon Apr 7, 2017
Dude, not responding over and over won't make me think the answer is: "I have no time".
Sorry ;)
sethmlarson commentedon Apr 7, 2017
Many people in open source would rather spend time actually working on projects (or heaven forbid, anything but open source) rather than triaging the hundreds of notifications you receive daily. Please be respectful to everyone's time. If the issue is really pertinent, you might take a first stab at a PR, even if it's not complete, just to generate discussion and possibly bring in others to help tackle this issue.
We're all in this together. :)
omani commentedon Apr 7, 2017
yes that's the way to go. but since bitprophet told us that he would have a look into this I wanted to get some feedback about his progress.
omani commentedon Jul 1, 2017
hi bitprophet,
what is the status of this issue?
ploxiln commentedon Jul 2, 2017
You can browse the issue and pull request activity of this project yourself. If you do, you will see that there is no progress being made on this feature. Asking periodically only results in "noise". The fastest way for you to get this feature in paramiko would most likely be for you to implement it yourself.
cpatulea commentedon Jan 21, 2018
For sftp, it is relatively easy to connect SFTPClient to an ssh subprocess with mux:
vsoch commentedon Dec 10, 2021
heyo! Any recent discussion or updates for this issue? I was so excited to find paramiko but missing this functionality is going to make it not an option for the tool I'm developing (very sad!)
vsoch commentedon Dec 10, 2021
This thread has a couple of jumps to other issues and PRs - just wanted to link to (what I think is) the most recent / up to date and say I would really like to see this merged!
#1931
I tested for my use case, worked perfectly.
bitprophet commentedon Mar 12, 2022
Just tried out #1931, left this comment there and then realized it's silly to keep splitting discussion across various PRs. Here:
Have (yet another!) rebase of this locally to test it out. (edit: see https://github.com/paramiko/paramiko/tree/1931-int)
I may have missed it in the various comments but I had to remember how to use ControlMaster and grok things enough to realize that this does still omit the initialization of the socket, so recording exactly what I've done here for posterity. Or in case I don't merge it today, as I'm still hesitant (see below).
Initialization using OpenSSH (8.6) - could use
-nor whatever I guess, meh:This leaves
control.sockaround. In reality one would useControlPath=/tmp/my-box-o-sockets/%Cor similar... (also, I did just merge support for that token in config file parsing...)Fabric snippet to use that socket and this PR:
Invoking it show this on the client side (along with all the invoke/fabric level bits):
and in the other terminal which had its stdout/err linked to the controlmaster process, we see the OpenSSH debug out:
So as advertised and noted by a bunch of folks, yay! It kinda works.
Unfortunately it still has a lot of drawbacks:
sshto run stuff 😁I'm torn between "merge it for folks who need the base-case that does work" and "we will get TONS of people assuming this is fully-baked ControlMaster support and filing endless tickets about its shortcomings".
Might be able to have our cake and eat it too by pursuing that "different constructor" idea - so that it's not quite so obvious a "new feature" but a clearly marked "if you use this, you are off-roading until we pave it". Still means all those small code branches are there to possibly trip up regular users if there's bugs, but hopefully not.
For now I'm not going to merge this for 2.10 but I'll try to tidy up the related tickets and get all still-interested eyes in here for more discussion, and have myself more of a think, and perhaps we can add this experimentally in the next feature release. Having "experimental features" is something I should probably figure out anyways - it would give tickets like this a pressure release with, arguably, a fig leaf that I can wave at people who try whining about how it doesn't work.
ghost-ng commentedon Mar 12, 2023
@bitprophet - tracking the back and forth here and last note I see here is a potential for release, just want to follow up and/or make sure i'm looking in the right place for the version that includes this feature. cheers!
ghost-ng commentedon Mar 19, 2023
@bitprophet I'd like to sponsor this change - how to i go about doing that?
bitprophet commentedon Mar 22, 2023
@unkn0wnsyst3m a) yes, following this ticket is the best way to tell whether it's been merged/released/made redundant (the line item I left about code org / constructors, for example, may tie into work I'm about to start re #387), and b) I'm afraid I don't accept feature-specific bounties at this time (though I appreciate the offer!).
Please rest assured that this is still a ways up my priority list (mostly under the "we should strive to match OpenSSH features when we can" header), it's just not at the very top yet.
samayvar commentedon Mar 12, 2024
Hi, @ghost-ng @bitprophet, any update when this change of multiplexing will be released?