I’ve cooked up a Debian 7 virtual machine (with VirtualBox) in an attempt to play with setting up my own server and other such cool tricks. This is all on one computer.

I can SSH into the virtual machine via putty, but after a short (inconsistent duration, ~15 seconds to ~3 mins) period I get booted off the server with the good 'ol error.

Server unexpectedly closed network connection.

Naturally, I just changed my putty settings so that I will send a keepalive every 25 seconds.

This didn’t work, and now I'm straight out of ideas as to what to do to stop this, and I don't know if my error is somewhere in sshd_config or my putty configurations or any host of other possible things. Spending a while on Google also hasn’t turned up anything.

Looking through my sshd logs, my putty error logs, and my sshd_config isn't showing anything out of the ordinary.

EDIT: Here is my putty error log:

2015-02-20 15:03:28     Looking up host ""
2015-02-20 15:03:28     Connecting to port 3022
2015-02-20 15:03:28     Server version: SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2
2015-02-20 15:03:28     Using SSH protocol version 2
2015-02-20 15:03:28     We claim version: SSH-2.0-PuTTY_Release_0.63
2015-02-20 15:03:28     Doing Diffie-Hellman group exchange
2015-02-20 15:03:28     Doing Diffie-Hellman key exchange with hash SHA-256
2015-02-20 15:03:28     Host key fingerprint is:
2015-02-20 15:03:28     ssh-rsa 2048 ------------------------------
2015-02-20 15:03:28     Initialised AES-256 SDCTR client->server encryption
2015-02-20 15:03:28     Initialised HMAC-SHA-256 client->server MAC algorithm
2015-02-20 15:03:28     Initialised AES-256 SDCTR server->client encryption
2015-02-20 15:03:28     Initialised HMAC-SHA-256 server->client MAC algorithm
2015-02-20 15:03:32     Sent password
2015-02-20 15:03:32     Access granted
2015-02-20 15:03:32     Opening session as main channel
2015-02-20 15:03:32     Opened main channel
2015-02-20 15:03:32     Allocated pty (ospeed 38400bps, ispeed 38400bps)
2015-02-20 15:03:32     Started a shell/command
2015-02-20 15:04:56     Server unexpectedly closed network connection

EDIT x3: Here are the relevant results of an example failed session after looking at /var/log/auth.log.

Feb 21 16:16:38 CGIT sshd[2559]: Accepted password for web from port 60037 ssh2
Feb 21 16:16:38 CGIT sshd[2559]: pam_unix(sshd:session) session opened for user web by (uid=0)

EDIT x2:

I've reinstalled debian in a new VM instance (this time through a CD install instead of a netinstall) and yet I still get disconnected randomly. This happens when running the VM as admin, and disabling all antivirus.

  • Did you check SSH server log to see why it disconnects you? Did you check PuTTY event log? – Martin Prikryl Feb 20 '15 at 10:14
  • Which type of keepalive are you using? (It's not the TCP one, but the SSH one you need.) – roaima Feb 20 '15 at 10:15
  • @MartinPrikryl /var/log/auth.log isn't showing anything that seems out of the ordinary, but I can't say I'm looking in all the right places for certain. I've got the timer set to 30 seconds on the "connection" tab of putty, and have enabled TCP keepalives. Is there anything more I need to do? – druckermanly Feb 20 '15 at 10:22
  • Since I can't edit after 5 minutes: @MartinPrikryl Also, the putty event log just says "Started a shell/command" then (1 minute, 16 seconds later) says "Server unexpectedly closed network connection" with no other diagnostic information. – druckermanly Feb 20 '15 at 10:29
  • 1
    When you SSH into the server, try using the -v flag like this ssh -v [user]@[hostname] to set the SSH mode to debug and see what is actively happening on the connection. – JakeGould Feb 20 '15 at 22:34

Well, the error was a problem with VirtualBox.


If you have this error, you may upgrade to version 4.3.23 and your problems may be fixed.

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.