8

Local and remote os are all Debian8.
I want to keep ssh alive for a long time.
The configuration file /etc/ssh/ssh_config on my client(local) side.

Host *
    ServerAliveInterval 60
    ServerAliveCountMax 10000

The configuration file /etc/ssh/sshd_config on my server(remote) side.

/etc/ssh/sshd_config
TCPKeepAlive yes
ClientAliveInterval 60
ClientAliveCountMax 10000

It was tested that ssh connection can keep alive for a long time. There is a parameter in /etc/ssh/ssh_config ,ConnectTimeout , What does it mean?
Do ConnectTimeout 0 or ConnectTimeout 1000 take different effect?

Uriel
  • 123
  • 3
showkey
  • 115
  • 1
  • 4
  • 19

2 Answers2

13

man ssh_config

/ConnectTimeout

ConnectTimeout Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This timeout is applied both to establishing the connection and to performing the initial SSH protocol handshake and key exchange.

studgeek
  • 313
  • 2
  • 7
user9517
  • 115,471
  • 20
  • 215
  • 297
  • 11
    As the original author of this option, just a word of caution: the man pages was initially correct, but ConnectTimeout was later used for other purposes. Currently the timeout also apply for the initial SSH handshake as well. I will propose a patch for this. – Uriel Jul 13 '19 at 12:09
  • 5
    Manpage patch proposed: https://bugzilla.mindrot.org/show_bug.cgi?id=3035 – Uriel Jul 13 '19 at 13:53
  • 2
    Patch to manpage was commited on Sep 13, 2019 https://github.com/openssh/openssh-portable/commit/2ce1d11600e13bee0667d6b717ffcc18a057b821 – Uriel Aug 07 '20 at 11:58
  • 2
    I submitted an edit to the Answer with the updated ConnectTimeout description. – studgeek Sep 08 '20 at 22:46
3

How I remember, Connection timeout is a time when server writing for connection if host unreachable. If you fill it by 0 and client will has connection problems server will close connection immidietly when clients connection losts