You can also just set client keepalives. Set TCPKeepAlive in ~/.ssh/config. This has solved a bunch of random timeout problems due to carrier NAT or similar. On Sat, Sep 15, 2018 at 15:36 Constantine A. Murenin <muren...@gmail.com> wrote:
> On 15 September 2018 at 09:50, Chris Bennett < > cpb_m...@bennettconstruction.us> wrote: > > > I am using my phone's hotspot, which may or may not be secure, but is > > not censoring my choice of sites to visit. Public WiFi in the USA does > > so all over the place. Worse, when I lived in Washington State, I was > > next to a Naval Air Station, which certainly eavesdrops, not OK, but > > this is the land of the free? Now I am living in the Capital of Texas, > > Austin which also leaves public WiFi under the same problems > > (legislature meets here). > > > > I cannot maintain an SSH connection unattended long enough to go to the > > bathroom and get a cup of coffee without the connection being dropped > > halfway through reading my email. > > > > Is autossh the right choice or is there a better way? > > The flow of data seems to be the problem. A static page disconnects. > > > > Thanks, > > Chris Bennett > > > > I also have T-Mobile US, and I cannot reproduce your problem. > > In fact, because my laptop gets a public IPv6 address from T-Mobile US — a > standard feature in Android 7.1.1, where you get at least a whole /64 from > the carrier — I can put it to sleep, disable AndroidAP, go get coffee, > lunch, dinner, or attend a meetup, or all of the above, come back home, > turn AndroidAP back on, turn my laptop on, and my vanilla ssh connection > will come back to live after a single keystroke (provided the phone was > never turned off and didn't itself lose network connectivity, e.g., still > has the same /64 assigned to itself). > > I did have to configure my laptop to `sysctl -w > net.inet6.ip6.prefer_tempaddr=0`, and also make sure I'm not running > something that'd be constantly refreshing the screen of the terminal I'm > accessing through ssh, e.g., you definitely do have to disconnect tmux with > the timestamp before you attempt this, and doing socks proxying would > obviously interfere with it as well if any connections remain open when you > attempt to turns things off like that, and — viola, problem solved. > > So, my suggestion — move to IPv6 for the killer features, and stop worrying > about the disconnects. > > But if you don't have a public IP address on your laptop and do get your > internet through NAT/CGNAT and/or a stateful firewall, then you might have > to play with `-oServerAliveInterval=480` or some such, as per > http://mdoc.su/o/ssh_config.5, but, otherwise, this option is actually not > only unnecessary, but is, in fact, harmful, as it may "detect" brief > periods of connectivity loss that you don't necessarily care about. > > P.S. Another option, if you don't necessarily care about scrolling, and/or > already use tmux within your ssh, is to use http://ports.su/net/mosh. > Personally, I prefer straight ssh through IPv6 to mosh, although sometimes > it does cause me to use my AndroidAP even in venues where the public > internet is available. > > Cheers, > Constantine.SU. >