I am using Macbook developing a client application.

I want to access server logs, so I opened a shell terminal and established a ssh connection to the server and access the log file there by executing

tail -f server.log

It works, but the remote ssh session will expire after certain amount of time, which needs me to establish the ssh connection again and access the server log file again.

How can I keep the remote session all the time without expiration?

  • Not duplicate, but related: unix.stackexchange.com/questions/20193/… – depquid Apr 4 '13 at 12:02
  • Is it dying after being idle a certain amount of time, or is it dying a certain amount of time after start whether idle or not? – Patrick Apr 4 '13 at 13:43
  • If the cause of the problem is that your network connection is unreliable, you might consider mosh. – Chris Down Apr 7 '15 at 16:44

If the log file has a stead flow of data and the connection drops, then the cause is either A. Your firewall has a maximum tcp session time. B. There is some kind of reset happening, such has a hiccup in the wifi.

If you control both sides, you can install mosh: http://mosh.mit.edu/ which will reconnect, even if you change IPs or put your computer to sleep.

On the other hand, if the flow of data has long pauses, then you may be hitting the max idle timeout. You can add this to your ~/.ssh/config

Host *
        TCPKeepAlive yes
| improve this answer | |

Try the SSH configuration as suggested by Georgyo's answer. If that doesn't work you're likely running up against some kind of connection time limit imposed by a firewall somewhere. If that's the case and you have no way of removing the timeout you can try using something like screen to keep the process running even when your ssh session disconnects. I use BYOBU for nearly everything anyway.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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