External SFTP doesn't work with enryption on

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 21
Operating system and version (eg, Ubuntu 20.04): XX
Apache or nginx version (eg, Apache 2.4.25): XX
PHP version (eg, 7.4): 7.4/7.3

The issue you are facing:
Can’t upload data to SFTP storage when encryption is enabled

Is this the first time you’ve seen this error? (Y/N):
yes

(as its first time working with sftp >> ftp got disabled by my hoster)

Steps to replicate it:

  1. enable server-side encryption
  2. connect to sftp server
  3. try to upload a file

The output of your Nextcloud log in Admin > Logging:

A lot of errors: happen:

Error PHP Error: Cannot modify header information - headers already sent by (output started at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/sabre/http/lib/Sapi.php:132) at /home/htechcc/public_html/cc/sda/nextcloud/apps/dav/lib/Connector/Sabre/File.php#691
2021-05-08T20:14:53+0200
Error PHP Error: Cannot modify header information - headers already sent by (output started at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/sabre/http/lib/Sapi.php:132) at /home/htechcc/public_html/cc/sda/nextcloud/apps/dav/lib/Connector/Sabre/File.php#691
2021-05-08T20:14:53+0200
Error PHP Error: Cannot modify header information - headers already sent by (output started at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/sabre/http/lib/Sapi.php:132) at /home/htechcc/public_html/cc/sda/nextcloud/apps/dav/lib/Connector/Sabre/File.php#691
2021-05-08T20:14:53+0200
Fatal webdav Sabre\DAV\Exception: Could not rename part file to final file
2021-05-08T20:14:53+0200
Error PHP Error: fclose() expects parameter 1 to be resource, boolean given at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php#859
2021-05-08T20:14:53+0200
Error PHP Error: fread() expects parameter 1 to be resource, boolean given at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php#858
2021-05-08T20:14:53+0200
Error PHP Error: fopen(sftpread://home/htechcc/next//pngwing.com(1).png): failed to open stream: “OCA\Files_External\Lib\Storage\SFTPReadStream::stream_open” call failed at /home/htechcc/public_html/cc/sda/nextcloud/apps/files_external/lib/Lib/Storage/SFTP.php#378
2021-05-08T20:14:53+0200
Error webdav renaming part file to final file failed $renameOkay: false, $fileExists: true)
2021-05-08T20:14:53+0200
Error PHP Error: Expected SSH_FXP_STATUS at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SFTP.php#2366
2021-05-08T20:14:53+0200
Error PHP Error: Expected SSH_FXP_ATTRS or SSH_FXP_STATUS at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SFTP.php#1400
2021-05-08T20:14:53+0200
Error PHP Error: fclose() expects parameter 1 to be resource, boolean given at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php#755
2021-05-08T20:14:53+0200
Error PHP Error: fopen(sftpwrite://home/htechcc/next//pngwing.com(1).png): failed to open stream: “OCA\Files_External\Lib\Storage\SFTPWriteStream::stream_open” call failed at /home/htechcc/public_html/cc/sda/nextcloud/apps/files_external/lib/Lib/Storage/SFTP.php#384
2021-05-08T20:14:53+0200
Error PHP Error: Expected SSH_FXP_ATTRS or SSH_FXP_STATUS at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SFTP.php#1400
2021-05-08T20:14:53+0200
Error PHP Error: fread(): Length parameter must be greater than 0 at /home/htechcc/public_html/cc/sda/nextcloud/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php#55
2021-05-08T20:14:53+0200
Error PHP Error: Expected SSH_FXP_ATTRS or SSH_FXP_STATUS at /home/htechcc/public_html/cc/sda/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Net/SFTP.php#1400
2021-05-08T20:14:53+0200
Error PHP Error: fclose() expects parameter 1 to be resource, boolean given at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php#859
2021-05-08T20:14:53+0200
Error PHP Error: fread() expects parameter 1 to be resource, boolean given at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Storage/Wrapper/Encryption.php#858
2021-05-08T20:14:53+0200
Error PHP Error: fopen(sftpread://home/htechcc/next//pngwing.com(1).png.ocTransferId1917088064.part): failed to open stream: “OCA\Files_External\Lib\Storage\SFTPReadStream::stream_open” call failed at /home/htechcc/public_html/cc/sda/nextcloud/apps/files_external/lib/Lib/Storage/SFTP.php#378
2021-05-08T20:14:53+0200
Error PHP Error: Declaration of OC\Files\Stream\Encryption::wrapSource($source, $context, $protocol, $class, $mode = ‘r+’) should be compatible with Icewind\Streams\WrapperHandler::wrapSource($source, $context = Array, $protocol = NULL, $class = NULL) at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Stream/Encryption.php#0
2021-05-08T20:14:53+0200
Error PHP Error: Declaration of OC\Files\Stream\Encryption::loadContext($name) should be compatible with Icewind\Streams\Wrapper::loadContext($name = NULL) at /home/htechcc/public_html/cc/sda/nextcloud/lib/private/Files/Stream/Encryption.php#541
2021-05-08T20:14:53+0200

Thanks in advance!