I often ssh to linux using putty. Sometimes directly ssh, sometimes invoke putty inside winscp by "open session in putty".

In some cases when I have two putty terminals connected, and type "exit" to quit one of them, the terminal does not close. It shows "logout" but remains open. It will close after I "exit" another terminal. But sometimes the terminal close right after I type "exit".

I would like to know what's the rules behind this.


This sounds like you have set the ControlMaster option in your ssh config file (or its equivalent for puTTY) to auto:


Enables the sharing of multiple sessions over a single network connection. When set to yes, ssh(1) will listen for connections on a control socket specified using the ControlPath argument. Additional sessions can connect to this socket using the same ControlPath with ControlMaster set to no (the default). These sessions will try to reuse the master instance's network connec‐ tion rather than initiating new ones, but will fall back to con‐ necting normally if the control socket does not exist, or is not listening.

Setting this to ask will cause ssh(1) to listen for control con‐ nections, but require confirmation using ssh-askpass(1). If the ControlPath cannot be opened, ssh(1) will continue without con‐ necting to a master instance.

X11 and ssh-agent(1) forwarding is supported over these multi‐ plexed connections, however the display and agent forwarded will be the one belonging to the master connection i.e. it is not pos‐ sible to forward multiple displays or agents.

Two additional options allow for opportunistic multiplexing: try to use a master connection but fall back to creating a new one if one does not already exist. These options are: auto and autoask. The latter requires confirmation like the ask option.

What this means is that after the first session is opened, additional sessions will use the same network connection instead of opening additional ones, thereby using up less bandwidth and possibly reducing latency.

However, this also means that, until every other session has ended, the first "master" session cannot close its connection without also disconnecting those. Therefore, it will keep open until all other sessions have been terminated. (If you somehow force it to close, eg. by killing the puTTY task running the first connection, you will notice every otehr session closing as well.)

  • So any command to identify which session is master (first) session? – michael morgan Mar 22 at 20:21
  • Unless you're in the habit of opening multiple windows at the same time or reordering them, it should be the leftmost one in the taskbar. – Entropy0 Mar 23 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.