This keeps hapenning on which ever server I am connected to. I type:

ssh user@server

I log in, everything works for a couple of minutes. But after some time, possibly when I switch to other programmes (browser, ftp client etc) when I try to type anything back in the terminal, the cursor stops blinking while I type, but nothing actually gets typed. I can't execute any command, and all I can do is close the terminal window, reopen it and reconnect.

If it's of any importance, I'm running Ubuntu 12.04 on my local machine.

  • Many (cheap) NAT routers will drop idle connections. How quickly depends a bit on how busy they are and the size of their buffers. You may mitigate the problem somewhat by enabling TCP keep alive in your SSH client as well as the configuration of the SSH daemon. – HBruijn Jul 9 '14 at 14:59

You have a NAT router or a similar stateful firewall between your client and the server. When you opened the TCP session, the firewall remembered that a TCP connection was created between your client port and the server port. As long as the firewall remembers the connection, it will continue passing packets between the client and the server.

The session "breaks" because the firewall forgets about the connection and stops passing packets through. The firewall may forget about the connection because it has a timeout on idle connections. Or it could forget because it has a limited amount of memory and too many new connections were being created for it to remember all of them.

ssh has some options to work around this by sending periodic "keep-alive" packets when the connection is idle. Look at the TCPKeepAlive, ServerAliveInterval, and ServerAliveCountMax options.

| improve this answer | |
  • Thanks Kenster for taking the time to explain it to me. I'll see if the options you've mentioned will help. – Томица Кораћ Jul 9 '14 at 15:30

For what it's worth, instead of closing the terminal window, you can abort the ssh session by typing Enter ~ . consecutively.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.