Here's my setup:

Workstation==ssh=>jumphost(tmux with split panes)==ssh=>server1

If either of the two connections to the servers becomes unresponsive, how can I terminate them?

Sending ~. is not a convenient option as it would terminate the first ssh session.

  • Is there some way for you to retrieve the PID ? Like running top, typing L and then ssh ? Then you could kill -9 <pid> May 31 at 12:25

2 Answers 2


In order to kill a nested ssh session, without afecting the parent, the inner session needs to receive the escape key.

You start the escape sequence by pressing enter, followed by ~ then ~, this sends a escape to the inner session. then you can follow it up with . to kill the inner session

  • For some reason that didn't work when I tried it before asking this question, but after trying again it does. Thank you
    – Philippe
    May 31 at 12:35
  • You could also change the escape character for the inner and outer sessions.
    – Barmar
    Jun 1 at 15:12

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .