Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

closed as not constructive by Tom Wijsman, HackToHell, Simon Sheehan, 8088, TFM Dec 8 '12 at 23:05

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What is good? –  Tom Wijsman Dec 8 '12 at 10:29
    
It's defined in the OP - good is pausing rather than dropping my connection –  kfmfe04 Dec 8 '12 at 10:34

2 Answers 2

up vote 1 down vote accepted

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
share|improve this answer
    
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 Dec 8 '12 at 10:40
    
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 Dec 8 '12 at 10:43
    
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 Dec 8 '12 at 10:50
    
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 Dec 8 '12 at 10:53
1  
accepted - 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 Dec 8 '12 at 11:43

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.