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.

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
add comment

1 Answer

up vote 6 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

~/.ssh/config

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
add comment

Your Answer

 
discard

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.