[Bug 3456] New: provide a way to have forwardings killed, when the remote command/shell finishes

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Wed Jul 6 07:34:39 AEST 2022


            Bug ID: 3456
           Summary: provide a way to have forwardings killed, when the
                    remote command/shell finishes
           Product: Portable OpenSSH
           Version: v9.0p1
          Hardware: Other
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: ssh
          Assignee: unassigned-bugs at mindrot.org
          Reporter: calestyo at scientia.org


When having a ssh connection, that sets up some forwardings (I tried
with LocalForward) and that executes a remote command (but I guess it's
the same when having not remote command but logging in
interactively)... the ssh connection is kept open as long as its
forwarding is still used by some connection, even when the remote
command/shell has finished.

AFAIU, that’s intentional behaviour and indeed it makes quite some
sense for many cases.

But I think there may be other use cases, when any forwardings shall be
killed once the remote command/shell has finished

I stumbled over this while doing the following:

I have a connection which sets up port forwardings for a VNC server and
the connection also executes a remote command which cleverly handles
starting that VNC server and also stopping it on Ctrl-C but e.g. not on
SIGHUP (i.e. accidental SSH connection loss).

That all works quite well, but in one case the SSH connection remains
open, even though the VNC server has already been stopped and the
remote command has finished.

This happens, when I actually connect to the VNC server with some
client, and quit the VNC server from within that X session.

It then stops the VNC server, my remote command also notices this after
a while, but netstat still shows me a connection from local to remote
which stays in CLOSE_WAIT forever.
Ctrl-C causes ssh to quit, also when I stop remmina (the VNC client I

Guess there must be some issue with closing the connection when the
server is exited.

Anyway... from the SSH point of view it would be nice to be able to
forcefully kill any such forwarded connections, because it's already
clear that as soon as the remote command is finished, not connections
won't be possible anymore.


You are receiving this mail because:
You are watching the assignee of the bug.

More information about the openssh-bugs mailing list