I think this other answer is good, it would probably be my first choice. An alternative is to use what tmux provides, like this:
Type prefix,x (the default prefix is Ctrl+b). Confirm you want to kill the pane.
Processes running in the pane will get SIGHUP. Regardless if ssh
is a direct child of tmux
server of if there's a shell between tmux
and ssh
, ssh
should get SIGHUP and exit*.
There may be other processes that will get SIGHUP, in particular the shell (if any) between tmux
and ssh
. Ask yourself if it's OK for you.
While the other answer is specific to ssh and does not depend on tmux, this answer is specific to tmux and does not depend on ssh (it can be used to terminate other programs inside tmux).
* Unless it was run with nohup
or so. The main job of nohup
is to make a process immune to SIGHUP.
top
, typingL
and thenssh
? Then you couldkill -9 <pid>