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

I am using Macbook developing a client application.

I want to access server logs, so I opened a shell terminal & established a ssh connection to the server & access the log file there by executing tail -f server.log

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

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

share|improve this question

migrated from Apr 4 '13 at 19:37

This question came from our site for professional and enthusiast programmers.

You might be better suited to ask this on, say, "super user" or perhaps "unix & linux", or even "ask different". You'd have to check their FAQs though to know for sure. – J. Steen Apr 4 '13 at 11:29

Use autossh on your Mac in conjunction with tmux or gnu screen on the server.

If you use a package manager on your Mac you will probably find that they're packaged.

share|improve this answer

One way of several to do this is to add the following line

   ServerAliveInterval 60

beneath the "Host *" stanza in the file /etc/ssh_config.

Since adding that line about a month ago, my ssh sessions have not timed out whilst tailing log files.

The file suggests looking at the ssh_config(5) man page for more information.

Here's my entire ssh_config file, with comments stripped out:

[mini-nevie:/etc] nevinwilliams% grep -v "^#" /etc/ssh_config

 Host *
   SendEnv LANG LC_*
   ServerAliveInterval 60

Host *
    XAuthLocation /opt/X11/bin/xauth
share|improve this answer

Your Answer


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