Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometims I need to keep ssh connection alive for hour or even more.

Mysql big dumps or big TAR archives, for example, may require persistent connection for a long period of time. But Iam keep getting broken pipe error.

System is MacOs Lion.

How I can keep connection alive?

share|improve this question
up vote 7 down vote accepted

If you can do it, the best way is to install screen on the remote server, and run your long processes within screen. If your ssh session drops out for any reason (including timeout or simply a lost connection) the processes you are running will continue, and you can reconnect to them once you re-establish connection.

If this is not an option, then create


and enter the line

ServerAliveInterval 240

Change 240 to a number of seconds appropriate to send a keep-alive to maintain a session.

share|improve this answer
ServerAliveInterval is the solution. – Jevgeni Smirnov Dec 27 '11 at 11:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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