Repository navigation
Conversation
Basic support - Transport connect via Unix domain socket, and bypass the protocol/kex/userauth stages, and just use proxy. Some jiggling of the packetizer pad byte calculations
ControlMaster proxy seems to forward global_request messages, but swallows the global_response, so the proxied client should never wait for the response. For tcpip-forward, the client can't distinguish between success and failure. kex_init is even more borky, it seems. The proxy forwards the initial kex_init, but fields the server reply as a server initiated kex_init, so the ContolMaster sends another kex_init in response. The server, upon getting a kex_init message while already processing the proxied one, boots the connection altogether (per RFC4253 7.1)
Rather than complicate the retry logic, have Transport raise exception, and allow retry only within SSHClient. Change mux_path to controlpath, to be more consistent with OpenSSH terminology
|
For anyone who got "unsupported request" error, you need openssh-client 7.4p1 or newer. |
plus a typo I'm just going to attribute to spellcheck
Good catch - I did not realize this was a relatively recent addition to the mix protocol, and a bit surprised that the protocol version number didn't get bumped along with that change so it could be caught cleaner than that. Added that detail to the exception message. |
|
This works great. Any thought to adding the initialization/management of the ControlMaster connection and ControlPath file via paramiko rather than relying one that is already up and running? |
|
The mux server side implementation can be done, but is going to be a significant amount of work. It probably needs to be a full implementation covering both proxy mode (which I used in the client implementation here) as well as passenger mode, that makes use of directly passing file handles, that is supported by the Python3 standard library, but would need another dependency added for Python2 support. |
|
I confirmed this patch works for me. It saved me from annoyance. Great! 👍 |
|
The shared connection closed periodically when I was using this PR. It does not happen every time but if you keep trying (for about 5 times or more), ssh will disconnect itself from the server. Here is the error message,
I tried to find the cause but with no luck. My program exited normally and no exception was thrown. FYI, I created a context manager to close the client automatically. |
|
@radssh Please take a look at the log. |
|
At a glance, the paramiko log (and the ssh client log for the ControlMaster) seem to indicate that the connection is getting dropped. I will do some code testing, based on the log, using the sftp for file transfers. I tried your earlier code sample, and it looks like your context manager isn't really a context manager. I'm getting |
My bad, I forgot to paste some import statements. Yeah, I'm using sftp to transfer files because the bastion host says ssh2. I tried doing the same task using command line tools and the error never showed. So I guess there might be something wrong with paramiko. I've uploaded my real program. My shared connection gets closed each time I run it. I changed its extension since Github does not accept .py. You have to modify some variables' values in the main function, otherwise the program won't work. Thanks for your help. I really appreciate it. |
|
I would love to see this merged, even if only the ability to piggyback onto an existing socket. |
|
I just tried this and it works fine to connect, however when Paramiko disconnects it also hangs up the master. Afraid I know little about ssh and networking so can't contribute to the patch |
|
I have rebased this as #1857. What do people think about having a separate method for connecting to a multiplexing socket, rather than an extra parameter to the |
|
Rolling into #1931. |
Draft implementation for #852
Seems to work fine for normal open_session management, some quirks with port forwarding and global request/response handling, and catastrophic behavior if renegotiate_keys is called when in proxy mode :)
Some guesswork needed, as the OpenSSH client uses "passenger mode" instead of "proxy mode", but proxy mode seems a much better fit for paramiko, since the SSH protocol messages are already implemented, and the proxy mode only required a small set of changes to the packetizing (zero padding failed to work due to modulo calculation)
Supply a (new) controlpath parameter to
Transport()orSSHClient(), and domain socket connection is attempted. If successful, it confirms that is is talking to a ControlMaster server, and switches the ControlMaster session into Proxy mode. The Transport then behaves as an authenticated transport, skipping the initial hostkey validation, key exchange, and user auth.