How can I stop a terminal connection from timing out

5,167

I used to have the same issue with two Ubuntu boxes. There are settings in /etc/ssh/ssh_config that you can play with if you have root access, otherwise in your home folder .ssh/config try adding:
Host *
ServerAliveInterval 500
Otherwise there is a tool called "autossh" which will automatically reconnect on disconnect. You'll need to exchange keys if you want it to be fully automatic - and your session could get screwed up if you aren't using something like byobu or screen.

Share:
5,167

Related videos on Youtube

Giveme
Author by

Giveme

Updated on September 18, 2022

Comments

  • Giveme
    Giveme over 1 year

    At work I have two machines: Windows XP and Ubuntu 11.04.

    On my XP machine I use Putty to connect to some servers and can leave those windows open for weekends without them timing out.

    However, when I connect tot the same serves from my Ubuntu box with Terminal, my connection times out before I even return from lunch or a meeting.

    Is this by design or is there a setting i am missing?

    • psusi
      psusi almost 13 years
      Do you have the Ubuntu machine set to automatically suspend after a period of inactivity? I recently ran into this problem with my new Windows 7 machine at work since it defaults to suspend after like half an hour, so when I got back from lunch and woke it up, the ssh connection was reset.
    • Giveme
      Giveme almost 13 years
      It wasn't a sleep/suspend issue in this particular case. The only thing to occur is the screen saver turning on after a period of inactivity.