Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ahoelzemann opened this issue Mar 2, 2022 · 5 comments
Open

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

ahoelzemann opened this issue Mar 2, 2022 · 5 comments
Assignees

Comments

@ahoelzemann
Copy link

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.

@xtyxtyx xtyxtyx self-assigned this Mar 2, 2022
@ahoelzemann
Copy link
Author

ahoelzemann commented Mar 2, 2022

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 ahoelzemann changed the title error code 4 when I'm trying to upload a file via sftp error code 4 when I'm try to upload a file via sftp Mar 2, 2022
@ahoelzemann ahoelzemann changed the title error code 4 when I'm try to upload a file via sftp error code 4 when I try to upload a file via sftp Mar 3, 2022
@xtyxtyx
Copy link
Member

xtyxtyx commented Mar 3, 2022

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?

@ahoelzemann
Copy link
Author

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?

@xtyxtyx
Copy link
Member

xtyxtyx commented Mar 4, 2022

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.

@ahoelzemann
Copy link
Author

ahoelzemann commented Mar 6, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants