What can I do to configure my SSH such that it pauses for a flaky connection?

1

I run ssh from OSX to a Ubuntu box - under home WIFI, everything works perfectly.

However, when I ssh from certain external networks, ssh may be working fine for a minute or two and then drop due to a flaky network (diagnosed by pinging 8.8.8.8).

How can I set up ssh so that it simply waits/pauses rather than drop (when dropping, I have to setup my development environment from scratch - a big hassle).

EDIT When I say a bad connection, I mean, for example, ping 8.8.8.8 will work fine for a while, and then fail for 40-50 pings, and then come back on again.

kfmfe04

Posted 2012-12-08T09:59:32.213

Reputation: 645

Question was closed 2012-12-08T23:05:37.723

What is good? – Tamara Wijsman – 2012-12-08T10:29:27.227

It's defined in the OP - good is pausing rather than dropping my connection – kfmfe04 – 2012-12-08T10:34:35.787

Answers

1

Always check the manpages if you are unsure. In this case man ssh and man ssh_config.

From man ssh_config

 ConnectTimeout  
         Specifies the timeout (in seconds) used when connecting to the
         SSH server, instead of using the default system TCP timeout.
         This value is used only when the target is down or really
         unreachable, not when it refuses the connection.

You can either write this to your ssh_config file or pass it to your ssh command directly:

ssh -o ConnectTimeout=$SECS $HOST

Baarn

Posted 2012-12-08T09:59:32.213

Reputation: 6 096

Just tried it out with a value of 60, connected to my server in LAN, removed the ethernet cable, waited about 30 seconds and plugged it back in, connection was catching back up. – Baarn – 2012-12-08T10:40:16.647

thx for your answer - tried it out with a setting of 120, the network went out for 22 seconds, but the session still disappeared - there must be something else. fwiw, this is on a wifi network in a coffee shop - ping to the local wifi router also fails (not just ping to the internet) - probably due to high concentration of wifi routers in the area. – kfmfe04 – 2012-12-08T10:43:33.573

In my case I disconnected my laptop from the switch that connects to my router (same as server). I am just guessing here, but maybe the router in that coffee shop refreshes the NAT-table when your connection drops. In that case I don't see any chance for you. – Baarn – 2012-12-08T10:50:48.413

I tried connection to an external server with above setting, pulled the plug and it worked again, at least in my case my router can reassign the address. – Baarn – 2012-12-08T10:53:22.027

1accepted - my fix turned out to be changing the DHCP to my hand-picked IP setting - this implies that somehow my IP was stale/colliding with someone else on the subnet. Oddly, arp -a didn't reveal anyone else with the same IP. But after manually fixing a different IP, the problem hasn't resurfaced... – kfmfe04 – 2012-12-08T11:43:29.750

1

How can I set up ssh so that it simply waits/pauses rather than drop (when dropping, I have to setup my development environment from scratch - a big hassle).

Increase the TTL value of the packets as well as increasing the timeout of the connection.

Tamara Wijsman

Posted 2012-12-08T09:59:32.213

Reputation: 54 163