dartssh2 icon indicating copy to clipboard operation
dartssh2 copied to clipboard

error code 4 when I try to upload a file via sftp

Open ahoelzemann opened this issue 2 years ago • 5 comments

I'm try to upload some data from my the smartphone to a server via sftp. However, I keep on receveing an exception with the error code 4. The error message is only "failure", so it's pretty hard for me to understand what is going on.

I'm able to connect to the server and to create folders, but the upload itself is not working. The code itself is copied from your readme page. Both variables, serverPath and localFilePath are valid paths.

    final file = await sftp.open(serverPath, mode: SftpFileOpenMode.create | SftpFileOpenMode.write);
     await file.write(File(localFilePath).openRead().cast());

thank you and best regards.

ahoelzemann avatar Mar 02 '22 13:03 ahoelzemann

Dart Version 2.16.1 Flutter Version: 2.10.1

I will attach the corresponding exception

flutter: SftpStatusError: Failure(code 4)
flutter: SftpStatusError: Failure(code 4)
flutter: #0      SftpClient.open (package:dartssh2/src/sftp/sftp_client.dart:63:5)
<asynchronous suspension>

ahoelzemann avatar Mar 02 '22 13:03 ahoelzemann

The OpenSSH SFTP server use 'Failure' message for many errors and it's hard to tell the specific reason. This usually happens when the permissions is not enough, or the filesystem is read-only. Does your account have enough permission to write to the remote destination?

xtyxtyx avatar Mar 03 '22 14:03 xtyxtyx

Hey, thank you very much for quick answer! permission is granted, I also tried out the admin user of the server. Do you have another idea?

ahoelzemann avatar Mar 03 '22 18:03 ahoelzemann

Currently I have no other ideas about the error. However it may help to inspect the logs from sftp-server and see what actually happened. Detailed instructions can be found here: https://access.redhat.com/articles/1374633.

xtyxtyx avatar Mar 04 '22 09:03 xtyxtyx

Thanks for the help @xtyxtyx . I don't get any specific error message.

It seems like the session closes immidiately.

Mar  6 18:35:01 xxxxxxx CRON[2024678]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar  6 18:35:01 xxxxxxx CRON[2024678]: pam_unix(cron:session): session closed for user root

Do you have any idea?

ahoelzemann avatar Mar 06 '22 18:03 ahoelzemann