I have a few servers running Ubuntu Server 12.04.4 LTS, and they have all had an intermittent problem with uploading files from my Windows development machine. Occasionally when an upload is started (via SFTP) the upload starts in the client, the file is created server side, then it times out. The file on the server remains at 0kb. It can be deleted or overwritten, but once this has occurred once, each subsequent file upload results in the same problem for a period of time, sometimes 5 minutes, sometimes hours. Downloads work normally. File size doesn't seem to matter (1kb or 50mb), different SFTP clients result in the same error. Pulling my hair out over this one, and all my searching has not turned up an answer.

Update: Using PHPStorm, I am still running into this same issue, but it gives a little more information. The upload progress bar completes, it spins for a while, then it says:

Failed to transfer file 'filename.ext': could not close the output stream for file "sftp://host.tld/filename.ext".

I tried turning off the firewall on the server, thinking maybe it was getting in the way (sudo ufm disable) to no effect.

Update 2 (2014-07-29) I have found that if I connect to an encrypted VPN, I never have this issue, and it fixes the issue if I enable it after having problems without it. This leads me to think that this is somehow connected to my ISP? Is this at all a possibility? The only difference in the traffic is that it is encrypted to the VPN source, which is NOT internal to the server (so the server is still seeing it as external traffic).

  • Does this windows system communicate with these servers in any way besides SFTP? Do you see the problem with any other programs? In particular, can you make an interactive SSH session from the PC to these servers without any trouble? – Kenster Jun 20 '14 at 15:20
  • Yes, I can connect via SSH and HTTP/S just fine to the server during this time. It doesn't seem to matter what SFTP client I use, they all encounter the error. – Quentin Skousen Jun 20 '14 at 15:23
  • So it's not something like a routing problem or IP address conflict. And SFTP traffic runs through an encrypted SSH pipe. So a firewall couldn't selectively allow SSH while blocking SFTP. Maybe something is blocking the disk writes? Are these servers running virus scanners? – Kenster Jun 20 '14 at 15:29
  • The one I'm currently having an issue with (I've had the issue with a lof of different servers over time) is a pretty standard Ubuntu Server headless install, with Apache, MySQL, PHP. I haven't set up any virus scanners or anything. – Quentin Skousen Jun 20 '14 at 15:31
  • The next thing I'd try is to inspect the server process handling the SFTP session. OpenSSH normally runs a program named "sftp-server" to handle SFTP sessions. Use your client to open an SFTP session to the server. On the server, find the sftp-server instance and run strace -p pid-of-sftp-server. Strace will start printing the system calls made by the program being traced. Then try to upload a file from the client. You should be able to see the system calls where sftp-server receives the command from the client, creates the target file, and tries to write to it. – Kenster Jun 20 '14 at 15:36

Use something like wireshark to see what packets are being generated and sent in both directions. Get to the lowest level you can and see what's actually happening.

  • I've never used wireshark, can that be used on a headless server? – Quentin Skousen Jun 20 '14 at 13:44
  • If you have a desktop environment installed and use VNC, yes. If you use the terminal only you can use tcpdump to monitor packets. – Safado Jun 20 '14 at 14:01
  • I used Wireshark on my client end to capture the port 22 traffic during a failed upload, however, I have no idea what it means... – Quentin Skousen Jun 20 '14 at 14:15

I'd check free disk space on the server or your user quota.

I'd expect some error message in this case, not timeout, but other indices indicate lack of disk space.

  • I've checked, and free space / disk quotas are not an issue. – Quentin Skousen Jun 20 '14 at 13:44

Try disabling your anti-virus software temporarily. I had this problem and disabling AVG 2014 allowed the uploads to proceed per normal from my dev PC to the server.

This could also be caused by Windows Defender and AVG trying to scan the same data stream at once if you have Windows 8, although I can't confirm the hypothesis.

  • I use NOD32 on Windows 7. However, I've updated the question with some more details that I have discovered. – Quentin Skousen Jul 29 '14 at 12:48
  • Have you tried disabling NOD32 temporarily to see? I don't believe antivirus software can scan a secure stream, so that may in fact be taking it out of the loop. – eComEvo Jul 29 '14 at 14:29

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.