ssh -O stop: socket removed at once, open sessions finish, master exits when idle (even with ControlPersist)
Tested on macOS OpenSSH_10.0p2. A master started with ssh -fN -o ControlMaster=yes -o ControlPersist=2100 -o ControlPath=/tmp/x/m host:
- ssh -o ControlPath=/tmp/x/m -O stop host prints 'Stop listening request sent.' and unlinks the socket immediately.
- A session already open on the master keeps running and exits normally (rc 0).
- The old master process exits as soon as its last session ends. ControlPersist does NOT keep a stopped master around.
- An idle master exits within about 1 s of -O stop.
That makes -O stop a safe way to recycle a master after sleep or a network change, since -O check keeps reporting a zombie master alive: stop it, then start a new master on the same path. A client that connects after the stop finds no socket and, with ControlMaster=no, logs in directly. Caveat: if the -O stop itself times out (wedged master), the socket is still there, and a restart that first runs -O check will adopt the zombie. Use -O exit and remove the socket in that case.