openssh icon indicating copy to clipboard operation
openssh copied to clipboard

Feature Request: Implement Cancel Socket/Port Forwarding

Open benlcb opened this issue 3 years ago • 2 comments

The Session::request_port_forwarding documentation states the following:

Currently, there is no way of stopping a port forwarding due to the fact that openssh multiplex server/master does not support this.

In ssh, you can cancel port forwarding for multiplexed connections like this:

ssh -S [path_to_multiplexing_socket] -O cancel -L/R [forwarding_addresses] 

So I don't see why this couldn't be implemented? Maybe I'm missing something. Will implement it myself if no one picks up the ticket or tells me why it won't work. :)

benlcb avatar Jan 04 '23 15:01 benlcb

I didn't support this mainly because the ssh mux doc told me so:

Note: currently unimplemented (server will always reply with MUX_S_FAILURE).

Perhaps the doc is out of date and it's actually supported.

Maybe I'm missing something. Will implement it myself if no one picks up the ticket or tells me why it won't work. :)

I will appreciate that! Please do submit a PR since openssh-mux-client is now in the development stage of a new crate openssh-proxy-client that is blocking on tokio-util and I'm been quite busy recently.

NobodyXu avatar Jan 05 '23 01:01 NobodyXu

Oh I see! I think that comment in the doc you linked is outdated, I implemented it locally for me and it seems to work. I'll explicitly confirm that it works & figure out what my employers open source policy is, then I'll create a PR!

benlcb avatar Jan 08 '23 14:01 benlcb

Hi @benlcb, sorry for bumping an old thread, but I ran into this need as well.

The doc mentioning that cancellation is currently not implemented was indeed outdated and was removed: https://github.com/openssh/openssh-portable/pull/442

If open-sourcing didn't really work out, could you perhaps describe the necessary changes at a high-level? I'm interested in contributing this feature.

jaywonchung avatar Sep 01 '24 19:09 jaywonchung