Is there a client side work-around for a too-short auto logout from an SSH connection?

7,270

Solution 1

Is it bash's TMOUT, or ssh? If it's TMOUT, there are a couple options listed here.

https://stackoverflow.com/questions/25675598/getting-kicked-out-of-openshift-server-after-a-while/25689720#25689720

Or
https://unix.stackexchange.com/questions/222283/read-only-tmout-variable-workaround-to-disable-automatically-exit-shell-when-t

-Erik

Solution 2

Add this line to $HOME/.ssh/config on the SSH client side:

ServerAliveInterval 60

Adjust the interval (60) to whatever works for your situation. See the man pages for details.

I hope it helps.

Share:
7,270

Related videos on Youtube

Camille Goudeseune
Author by

Camille Goudeseune

Programmer, researcher, and church organist.

Updated on September 18, 2022

Comments

  • Camille Goudeseune
    Camille Goudeseune almost 2 years

    I SSH from one Linux host to another Linux host that I don't administer. Its /etc/ssh/sshd_config is apparently configured to auto-logout after an interval of inactivity that is too brief for my taste (How do I enable auto-logout of Interactive ssh logins after one hour).

    Is there any way to keep my SSH session alive, perhaps by sending or receiving a newline character every two minutes?

    Workarounds like while true { echo ' '; sleep 120 } were common in the days of dialup modems).

    FWIW, Windows' PuTTY isn't involved at all.

    • Erik Bennett
      Erik Bennett about 7 years
      Is it bash's TMOUT, or ssh?
    • Camille Goudeseune
      Camille Goudeseune about 7 years
      Well, ssh to other hosts doesn't time out. And $TMOUT isn't defined.
    • Camille Goudeseune
      Camille Goudeseune about 7 years
      Hm, that led me to unix.stackexchange.com/questions/222283/… . Post something like that as an answer, and I'll accept it.
  • fixer1234
    fixer1234 about 7 years
    Thanks for closing the loop on your question. Could you add a sentence or two to explain what this does?
  • Camille Goudeseune
    Camille Goudeseune about 7 years
    It's ssh, not TMOUT.
  • Camille Goudeseune
    Camille Goudeseune over 6 years
    This answers a different question. The original question is about what to do when you can't change the target host's configuration.