Incredibly slow performance with SFTP

Hello all,

Successfully gotten Nextcloud running on my web server! My goal however is to primarily use a Raspberry Pi running as a NAS at home for storage. I’ve successfully configured SFTP access and it’s all running however performance is INCREDIBLY slow. Uploads and downloads are probably moving at 30kb/sec or so. Hard to tell exactly but it’s painfully slow.

As a test just to be sure it wasn’t the Pi screwing everything up I connected to it with Cyberduck and was able to upload files to the same directory using the same user at over 1.5MB/sec.

The Pi is running Raspbian (Debian 8) and my OpenSSH version is 6.7. My webserver is running Ubuntu 16.04 / Apache 2.4.18 / PHP 7.0.8 / MariaDB 10.0.27.

I saw conversations about phpseclib potentially being the culprit for this problem for older versions of Owncloud but its from a few years back and appeared to have solved itself.

Any ideas anybody?

Thank you!

You need to test from a comuter outside your home network because your internet connection might be the bottleneck. If you can, test a sftp-connection to a different sftp-server (from your nextcloud) and also test a connection from a different nextcloud to your RPi.
Problems with openssl-ciphers should also show up in your logfiles (but then the connection normally fails).

Thanks for the note back. I can confirm that from an external location I was able to successfully connect via SFTP and was uploading to the RPi on my home network at 1MB/sec (copying a file from to the same directory on my RPi that Nextcloud is using as external storage - that user is chroot to it’s home directory which is where I’m storing files on an external USB drive).

Next to confirm my web server can connect to my home RPi I used scp. That was able to upload at 11.2MB/s. So… this doesn’t seem to be bandwidth constrained.

I don’t have an alternative Nextcloud to test from so that’s a challenge.

Any new ideas or suggestions to debug?



You could set up Nextcloud in a virtual machine on your home network…

We are also seeing slow performance from Nextcloud to external storage (in Mediaflux) via SFTP. We are essentially seeing:

  1. Create the remote file and close
  2. Open file, write 8KB chunk, close file
  3. Open file, write 8KB chunk, close file
    … and so on until the file has been copied to the remote location.

My understanding is that SFTP implementations normally open the file once, write the data, and then close the file, so this chunking does not appear to be expected behaviour. Is there a way to turn the chunking behaviour off through configuration?

Not only is this slow, but with Mediaflux, each close of the file creates a new version of the asset inside Mediaflux, which is definitely not desired (a 7 byte file resulted in 2 versions, a 4MB file had 520 versions).

If I connect using Cyberduck, the SFTP transfer is much quicker, and only 1 version of the asset is created inside Mediaflux.


1 Like

thanks for your investigation.
Maybe you could open an issue at Github?