Linux – PuTTY Network Error: Software caused connection abort

linuxputtysshtimeoutvmware

I have a strange problem: When I'm using PuTTY with SSH connecting to a Linux server hosted in VMware on my local Windows 7, I often get the error saying "Network error: Software caused connection abort" and then the PuTTY SSH window is inactive. Usually I can login in the server with PuTTY and do something, but after a random time (about one or two minutes) I get that error. And sometimes I even can't login, getting an error saying timeout.

I guess there's something wrong with my VMware Player, because I have another Ubuntu desktop hosted in VMware as a code repository server, and it more often than not has a timeout error when I do an SVN update/commit. However, I also guess Windows 7 has some quirk because the same Ubuntu server hosted in VMware as a code repository works very well when on Windows Vista! It seems all the bad things happen after I moved from Windows XP to Windows Vista and then Windows 7!

What could be the reason for this problem and how can it be fixed?

Supplement:

I did a Google search and applied all methods to help, including:

  1. Enable sshd TCPKeepAlive
  2. Set sshd ClientAliveInterval to 900 and ClientAliveCountMax to 3
  3. Set the PuTTY connection setting 'seconds between keepalives' to 5.

But these all don't work! And the SSH session in PuTTY still breaks after sometime!

I turned off both the Linux server firewall and Windows 7 client firewall, but login still times out! It is really annoying!

It seems sometimes I can log in, but sometimes login times out! I really don't know why. It drives me crazy!

One thing I have to mention is that when I'm using PuTTY SSH connecting to a remote server, and it's all OK!

When I failed to log in, ping failed too! But, how can that happen? I use VMware player to host the Linux server on my local machine!

Best Answer

Windows XP or prior Operating system only:

I wrote this answer 9 years ago for Windows XP, Putty software is 21 years old and so this answer is useful for historical purposes. Window's current smartphone-based Zune-OS for Desktop has broken Putty at the network level, in pursuit of irritating away all points of entry or exit that are not part of the pay-for-play Azure Vendor tool stack.

Putty has a feature which attempts to fix this problem:

Network Error: Software caused connection abort
  1. Start Putty
  2. Load your connection settings if you have them saved
  3. Click on “Connection”
  4. On the section that says "Sending of null packets to keep session active", Changed it to 5 seconds. 300 seconds may be better if network outages are your problem, read below for details.

enter image description here

How keepalives to prevent disconnection with Putty:

Some network routers and firewalls need to keep track of all connections through them. Usually, these firewalls will assume a connection is dead if no data is transferred in either direction after a certain time interval. This can cause PuTTY sessions to be unexpectedly closed by the firewall if no traffic is seen in the session for some time.

The keepalive option (‘Seconds between keepalives’) allows you to configure PuTTY to send data through the session at regular intervals, in a way that does not disrupt the actual terminal session. If you find your firewall is cutting idle connections off, you can try entering a non-zero value in this field. The value is measured in seconds; so, for example, if your firewall cuts connections off after ten minutes then you might want to enter 300 seconds (5 minutes) in the box.

Reduce the problem using putty autologin and "screen" tool

Putty cannot handle a crappy wifi that loses connectivity for minutes at a time. A work around is to use autologin and screen.

It is a non trivial problem for putty to re synchronize your terminal after a minute long loss in internet connection. You run risks of man in the middle attacks during an outage. You would have to re-authenticate yourself anyway to make sure. Putty doesn't impose that on you, it just drops you.

So use autologin so putty can auto login on your behalf.

  1. Generate a private key with the puttygen tool on the computer you are putty with.
  2. Paste the public key in your /home/youruser/.ssh/authorized_keys on the server side, on the server that you are using putty go login to.
  3. Make the private key accessible to putty in the putty settings Connection->SSH->Auth
  4. Add the private key by specifying the private key file under: "Private key file for authentication".
  5. Save the putty connection settings.

Then you would be able to double click your connection through putty, and it should take you right in to the terminal without typing username/password.

So now you can hook a login to putty on that connection with a keyboard combination like F6. So when the wifi goes bad and you get dropped. You mash down F6 and you're back logged in.

BUT you still lose the state of your terminal! How to fix that? Use the "screen" program. Make a new screen by typing 'screen'. A new screen is created.

When you get kicked out and auto login, you can reattach to your screen. Here is a tutorial on how to do that: http://www.tecmint.com/screen-command-examples-to-manage-linux-terminals/

It's a hassle to type in screen and reconnect every time you get dropped. So you can write a script that will "auto bring you back to the last available screen" to make it transparent.

So then when the putty terminal freezes. It looks like this: You make a snort of contempt, mash down Alt+F4 to close putty, Mash down F6. And in 6 seconds you are back right where you left off.

Even better solution, in theory

In theory you could script out this entire above process, so the terminal detects when it has been dropped, and does all the above steps for you on restoration of the internet connection. If anyone knows a program that does this automatically let me know. It would be neat.

Sources:

http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter4.html#config-keepalive

http://rafaelwolf.com/?p=516