Skip to content

Adding a clock in screen to avoid your ssh’s from being killed

The world is filled with stupid routers, which kill all connections that have no activity for a while (even a very short while). I keep loosing my SSH sessions because of this. To fix it, I added a clock in my GNU screen bar:

hardstatus alwayslastline "%= %H | %l | [%c:%s]"

For the record, my entire .screenrc:

multiuser on
caption always "%{= kB}%-Lw%{=s kB}%50>%n%f* %t %{-}%+Lw%<"
vbell off
startup_message off
term linux
hardstatus alwayslastline "%= %H | %l | [%c:%s]"

    5 Comments ( Add comment / trackback )

    1. (permalink)
      Comment by Rowan Rodrik
      On October 31, 2012 at 19:53

      Screenshot or it didn’t happen. 😉

    2. (permalink)
      Comment by halfgaar
      On November 1, 2012 at 13:18

      Blog with working image upload, or it didn’t happen 🙂 (or did you finally fix that…?

    3. (permalink)
      Comment by Rowan Rodrik
      On December 29, 2012 at 00:37

      Working image uploads. It just happened.

    4. (permalink)
      Comment by YC
      On April 12, 2013 at 11:24

      Alternatively you could set a ServerAliveInterval in .ssh/config so that it kind of sends a heartbeat signal if your connection is idle.

    5. (permalink)
      Comment by halfgaar
      On April 27, 2013 at 13:21

      How does that play with momentary connection dropouts? Because the server option TCPKeepAlive says this:

      However, this means that connections will die if the route is down temporarily

      man ssh_config doesn’t say such a thing about ServerAliveInterval, so I guess it’s fine.