SFTP external storage connects with RSA but is unable to write

Nextcloud version : 20.0.9.1
Operating system and version: Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18
PHP version (eg, 7.4): 7.4.3

The issue you are facing:
SFTP external storage connects with RSA but is unable to write
When connecting using alternative private key in FileZilla has the expected behavior.

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

Steps to replicate it:

  1. Add External storage SFTP with RSA Key auth
  2. Copy ssh-rsa public key to .ssh/authorized_keys
  3. Open External storage folder in nextcloud

The output of your Nextcloud log in Admin > Logging:

{"reqId":"nkzCZfkJeoP3ihYWwMgQ","level":4,"time":"2021-05-05T13:21:47+00:00","remoteAddr":"IP.ADD","user":"USER","app":"webdav","method":"PUT","url":"/remote.php/webdav/1326/padlocked.jpg","message":{"Exception":"Sabre\\DAV\\Exception","Message":"Could not rename part file to final file","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":156,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1104,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":527,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php","line":84,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v1/webdav.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","Line":296,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0","version":"20.0.9.1","id":"60929bf14e8d7"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'A',
  'passwordsalt' => 'A',
  'secret' => 'A',
  'trusted_domains' => 
  array (
    0 => 'A',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '20.0.9.1',
  'overwrite.cli.url' => 'A',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'A',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'A',
  'mail_from_address' => 'A',
  'mail_domain' => 'A',
  'mail_smtpport' => '587',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'A',
  'mail_smtppassword' => 'A',
);

I managed to create a folder from webdav but not upload files

Can you read from it?
Any logs and information from the sftp storage (in case it is yours)?

Yes I see the default linux user files but can’t write, only create folders through Linux nextcloud account


I don’t have any logs

I made a fresh installation with the latest version and can confirm that this is a bug with the default encryption module

In the fresh install I can connect to the external server and write files until I enable the default encryption module. Then it has the behavior described above.

Then it is something for the bug tracker: Issues · nextcloud/server · GitHub