3

I connect to my Ubuntu 14.04 VPS using putty. The connection used to just stay alive indefinitely. Now though I seem to be getting a disconnect after a certain amount of time.

I have done some Google searches but can't find something to solve my issue.

My /etc/ssh/sshd_config file has "TCPKeepAlive yes" set up in it. Is there some other setting I need?

The only changes I have made recently are that Installed and setup fail2ban.

10
  • Add ClientAliveInterval 120 to the /etc/ssh/sshd_config file and then check..
    – heemayl
    Jul 5, 2015 at 20:09
  • Thanks, I added it to my /etc/ssh/sshd_config and then typed "sudo service ssh restart". We will see how it goes now and if I get any disconnects.
    – timbram
    Jul 5, 2015 at 20:26
  • I have never been able to solve this issue myself, having tried adding the keep alive intervals suggested, using screen, whatever. I have had this issue in different computers connected to different networks, with different servers. Good luck.
    – Alex
    Jul 5, 2015 at 20:34
  • Do you get any error message on disconnection? Like "broken pipe" or something else? Jul 5, 2015 at 20:56
  • @EricCarvalho For me, the error is just something like "Network Error: Software caused connection abort". It happens in both Putty and WinSCP
    – timbram
    Jul 5, 2015 at 20:58

2 Answers 2

3

Maybe you deleted ~/.ssh/config by accident. Run in the remote system:

sudo nano ~/.ssh/config

And insert the following:

Host *

  ServerAliveInterval 60

Then type:

sudo service ssh restart

What it does is to tell the server that you are alive every 60 seconds.

2
  • If the network is aggressively disconnecting, you may need to set 60 to a lower number.
    – mchid
    Nov 4, 2019 at 22:19
  • This is for the client, not the server Jun 12, 2020 at 7:41
0

Sorry for my maybe dump answer: in your post you wrote that you made a change by setting up fail2ban.

Did you configure a jail for sshd?

If it is the case please try out if stopping the fail2ban server helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .