[Bug 3271] Interface to send commands to the server side ssh

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Mon Mar 8 19:58:00 AEDT 2021


https://bugzilla.mindrot.org/show_bug.cgi?id=3271

--- Comment #5 from Darren Tucker <dtucker at dtucker.net> ---
(In reply to Marcos Dione from comment #4)
[...]
> I want to run commands (as in shell commands, that I can then
> execute from any program) on the server that modifies the ports
> forwarded by the session established from the client to the server.

The port forward listen requests 

You could do that by combining ControlMaster and a remote forward of a
Unix domain socket:

client$ ssh -v -oControlMaster=yes -R/tmp/sock:/tmp/sock server
[...]

server$ $ ssh -oControlPath=/tmp/sock -O forward -L 1234:127.0.0.1:22
localhost
debug1: client_input_channel_open: ctype
forwarded-streamlocal at openssh.com rchan 5 win 2097152 max 32768
debug1: client_request_forwarded_streamlocal: request: /tmp/sock
debug1: connect_next: host /tmp/sock ([unix]:/tmp/sock) in progress,
fd=8
debug1: channel 2: new [forwarded-streamlocal]
debug1: confirm forwarded-streamlocal at openssh.com
debug1: multiplexing control connection
debug1: channel 3: new [mux-control]
debug1: channel 2: connected to /tmp/sock port -2
debug1: Local forwarding listening on ::1 port 1234.
debug1: channel 4: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 1234.
debug1: channel 5: new [port listener]
debug1: channel 3: free: mux-control, nchannels 6
debug1: channel 2: free: forwarded-streamlocal, nchannels 5

server$ $ telnet localhost 1234
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

client$ telnet localhost 1234
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
SSH-2.0-OpenSSH_8.5

The caveat is that the mux protocol is effectively internal to ssh, so
it'll only work with an OpenSSH client of of a compatible version being
run on both ends.  (There's been 4 revisions of the mux protocol in the
12 years since multiplexing was introduced, so while it doesn't change
often it does change.)

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list