Main /

SSH Master Cache

Navigation

Links

Useless Badges


All original content, unless otherwise noted, is licensed under a Creative Commons License.

@

SSH Master Cache

SSH Session Cache

OpenSSH 4 finally added a feature the ssh.com windows client has had for years: multiple connections over a single SSH connection. This means that once the first SSH connection to a host is made, opening a new shell or sftp connection skips the TCP and SSH handshakes, and just uses the stream multiplexing of the SSH protocol to share the original connection. They even added a nifty auto flag, which uses an existing session if it exists, and creates (and shares) one if it doesn’t.

So this is neat and all, because of course more features means more good. But things turn out to be not so rosy when you examine where this feature would really make a difference. Basically, who gives a damn unless the connection set up time significantly dominates the total connection time. Where does this happen? A bunch of serialized remotely executed commands for one. But the way the openssh feature is implemented, it only works for long, parallel connections (or at least one long one: the session master).

The solution to this I’ve seen suggested most is to just open up a master connection to each host with a null command in the background when you start for the day. This works, but its less than elegant, had issues with mobility, and requires more foresight than I posses. Instead, the usage pattern I described should have all good CS students raising their hand to shout out ‘temporal locality’ and ‘caching’.

The slick, right way to do this would be to modify openssh so that when auto is in use and an existing session does not exist, instead of the (possibly short lived) process becoming the master, a new child would be forked to be the master, which the original process would then use. This background ssh master session would then sit around until some user-defined time had passes since the last slave connected, when it would die.

The quicker, hackish way to do this would be to not use auto mode at all, wrap some error handling around the client to detect when the master session could not be found, and fire up a master and retry the slave.

Recent Changes (All) | Edit SideBar Page last modified on June 08, 2006, at 12:58 AM Edit Page | Page History
Powered by PmWiki