ssh loses response after about 2mins

Hello, I’m suffering from a ssh losing response problem these days. After about 2 mins inactivity after login, the ssh just loses responses and I have to force stop it.
I think it’s not the server’s problem because my other client machines works well.

I’m on 12.3 with gnome3.8 and following are some related output.

ssh version


ssh -V
OpenSSH_6.1p1, OpenSSL 1.0.1e 11 Feb 2013

settings in /etc/ssh/ssh_config


Host *
ForwardX11Trusted yes
Protocol 2
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL
VisualHostKey no
HashKnownHosts yes

ssh runtime output


ssh -vvv lynxiayel@xx.xx.xx.xx
OpenSSH_6.1p1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /home/lynxiayel/.ssh/id_rsa type -1
debug1: identity file /home/lynxiayel/.ssh/id_rsa-cert type -1
debug1: identity file /home/lynxiayel/.ssh/id_dsa type -1
debug1: identity file /home/lynxiayel/.ssh/id_dsa-cert type -1
debug1: identity file /home/lynxiayel/.ssh/id_ecdsa type -1
debug1: identity file /home/lynxiayel/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "xx.xx.xx.xx" from file "/home/lynxiayel/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/lynxiayel/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 122/256
debug2: bits set: 514/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA db:1b:8e:55:5c:67:78:93:b8:0d:2d:b8:b1:bc:7e:b7
debug3: load_hostkeys: loading entries for host "xx.xx.xx.xx" from file "/home/lynxiayel/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/lynxiayel/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "132.206.51.229" from file "/home/lynxiayel/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/lynxiayel/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'xx.xx.xx.xx' is known and matches the RSA host key.
debug1: Found key in /home/lynxiayel/.ssh/known_hosts:1
debug2: bits set: 536/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/lynxiayel/.ssh/id_rsa ((nil))
debug2: key: /home/lynxiayel/.ssh/id_dsa ((nil))
debug2: key: /home/lynxiayel/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/lynxiayel/.ssh/id_rsa
debug3: no such identity: /home/lynxiayel/.ssh/id_rsa
debug1: Trying private key: /home/lynxiayel/.ssh/id_dsa
debug3: no such identity: /home/lynxiayel/.ssh/id_dsa
debug1: Trying private key: /home/lynxiayel/.ssh/id_ecdsa
debug3: no such identity: /home/lynxiayel/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
lynxiayel@xx.xx.xx.xx's password: 
debug3: packet_send2: adding 48 (len 62 padlen 18 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to xx.xx.xx.xx ([xx.xx.xx.xx]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug3: Ignored env XDG_VTNR
debug3: Ignored env LIBOVERLAY_SCROLLBAR
debug3: Ignored env LESSKEY
debug3: Ignored env NNTPSERVER
debug3: Ignored env MANPATH
debug3: Ignored env XDG_SESSION_ID
debug3: Ignored env HOSTNAME
debug3: Ignored env DBUS_STARTER_ADDRESS
debug3: Ignored env XKEYSYMDB
debug3: Ignored env GPG_AGENT_INFO
debug3: Ignored env TERM
debug3: Ignored env HOST
debug3: Ignored env XDG_MENU_PREFIX
debug3: Ignored env SHELL
debug3: Ignored env PROFILEREAD
debug3: Ignored env XDG_SESSION_COOKIE
debug3: Ignored env HISTSIZE
debug3: Ignored env WINDOW_MANAGER
debug3: Ignored env TMPDIR
debug3: Ignored env GJS_DEBUG_OUTPUT
debug3: Ignored env WINDOWID
debug3: Ignored env MORE
debug3: Ignored env GNOME_KEYRING_CONTROL
debug3: Ignored env GJS_DEBUG_TOPICS
debug3: Ignored env XSESSION_IS_UP
debug3: Ignored env GTK_MODULES
debug3: Ignored env USER
debug3: Ignored env NO_UNITY_GTK_MODULE
debug3: Ignored env JRE_HOME
debug3: Ignored env LS_COLORS
debug3: Ignored env XNLSPATH
debug3: Ignored env HOSTTYPE
debug3: Ignored env SSH_AUTH_SOCK
debug3: Ignored env QEMU_AUDIO_DRV
debug3: Ignored env FROM_HEADER
debug3: Ignored env SESSION_MANAGER
debug3: Ignored env USERNAME
debug3: Ignored env CONFIG_SITE
debug3: Ignored env PAGER
debug3: Ignored env CSHEDIT
debug3: Ignored env XDG_CONFIG_DIRS
debug3: Ignored env MINICOM
debug3: Ignored env MAIL
debug3: Ignored env DESKTOP_SESSION
debug3: Ignored env PATH
debug3: Ignored env CPU
debug3: Ignored env JAVA_BINDIR
debug3: Ignored env QT_IM_MODULE
debug3: Ignored env INPUTRC
debug3: Ignored env PWD
debug3: Ignored env XMODIFIERS
debug3: Ignored env JAVA_HOME
debug3: Ignored env GNOME_KEYRING_PID
debug1: Sending env LANG = en_US.utf8
debug2: channel 0: request env confirm 0
debug3: Ignored env GDM_LANG
debug3: Ignored env PYTHONSTARTUP
debug3: Ignored env SDK_HOME
debug3: Ignored env UBUNTU_MENUPROXY
debug3: Ignored env GDMSESSION
debug3: Ignored env KRB5CCNAME
debug3: Ignored env ICEAUTHORITY
debug3: Ignored env DBUS_STARTER_BUS_TYPE
debug3: Ignored env AUDIODRIVER
debug3: Ignored env GPG_TTY
debug3: Ignored env SHLVL
debug3: Ignored env HOME
debug3: Ignored env QT_SYSTEM_DIR
debug3: Ignored env JDK_HOME
debug3: Ignored env XDG_SEAT
debug3: Ignored env LESS_ADVANCED_PREPROCESSOR
debug3: Ignored env ALSA_CONFIG_PATH
debug3: Ignored env SDL_AUDIODRIVER
debug3: Ignored env OSTYPE
debug3: Ignored env LS_OPTIONS
debug3: Ignored env XCURSOR_THEME
debug3: Ignored env GNOME_DESKTOP_SESSION_ID
debug3: Ignored env WINDOWMANAGER
debug3: Ignored env G_FILENAME_ENCODING
debug3: Ignored env LESS
debug3: Ignored env MACHTYPE
debug3: Ignored env LOGNAME
debug3: Ignored env CVS_RSH
debug3: Ignored env DBUS_SESSION_BUS_ADDRESS
debug3: Ignored env XDG_DATA_DIRS
debug1: Sending env LC_CTYPE = en_US.utf8
debug2: channel 0: request env confirm 0
debug3: Ignored env LESSOPEN
debug3: Ignored env WINDOWPATH
debug3: Ignored env XDG_RUNTIME_DIR
debug3: Ignored env DISPLAY
debug3: Ignored env STARTUP
debug3: Ignored env XAUTHLOCALHOSTNAME
debug3: Ignored env GTK_IM_MODULE
debug3: Ignored env LESSCLOSE
debug3: Ignored env G_BROKEN_FILENAMES
debug3: Ignored env QT_IM_SWITCHER
debug3: Ignored env JAVA_ROOT
debug3: Ignored env XAUTHORITY
debug3: Ignored env COLORTERM
debug3: Ignored env mc
debug3: Ignored env _
debug3: Ignored env OLDPWD
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Fri May 24 05:25:54 2013 from 135.0.227.115

after force close


debug2: channel 0: filter stops
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open -> drain
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i1/0 o0/0 fd -1/5 cc -1)


Connection to xx.xx.xx.xx closed.
Transferred: sent 2264, received 2072 bytes, in 144.6 seconds
Bytes per second: sent 15.7, received 14.3
debug1: Exit status -1

Any suggestions? Thanks in advance.

Are you SSH-ing from 12.3, to 12.3, or both? What if yo SSH from a system
to itself… does the disconnect still take place? Is your connection to
the other machine wired or wireless? Have you tested any other protocols
that maintain an open connection for minutes at a time?

I haven’t seen this on my 12.2 or 12.3 systems which are basically
configured out of the box w/regard to SSH, but I may be behind a few days
on patches (if applicable to SSH, etc.).

Good luck.

I had that happen at one time. It was the NAT router timing out its NAT table entries.

You can try setting a keepalive interval in “$HOME/.ssh/config”

Maybe:


        ServerAliveInterval       60

in the “Host *” entry (the default entry).

Thank @ab and @nrickert very much for the reply, I’ve tried add in the ServerAliveInterval field as @nrickert suggested, and now it works great!