0 votes
by (160 points)
edited by

I am trying to transfer file from one PC(Linux - client) to another PC( where Rebex Tiny Server is running - Windows). The connection is successful, but the code fails to transfer the file. The LIBSSH2_ERROR_SFTP_PROTOCOL error happens while trying to open the file specified as sftp_path (i.e the data folder in rebex).Attaching the code snippet.

 sftp_handle = libssh2_sftp_open(sftp_session, sftppath, 
               LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
               LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
               LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);

 if(!sftp_handle &&

           (libssh2_session_last_errno(session) == LIBSSH2_ERROR_SFTP_PROTOCOL)) {
        fprintf(stderr, "Unable to open file with SFTP\n");

        goto shutdown;

}
Applies to: Tiny SFTP Server

1 Answer

+1 vote
by (144k points)
selected by
 
Best answer

Make sure your path is correct. If it is, and your code still does not work, please instruct Tiny SFTP Server to log at Debug level and copy&paste the log here.

I just gave this a try and was unable to reproduce the issue. The file was created successfully. I used this C++ code for the client and compiled it on Linux using gcc upload.cpp -lssh2 -o upload command. The app succeeded and created an empty file. My Tiny SFTP Server log looks like this:

15:00:12.103 Debug Server: Accepted connection from 10.0.0.42:52404.
15:00:12.113 Info Server: Session 1: Started on connection from 10.0.0.42:52404.
15:00:12.117 Debug SSH: Session 1: Local SSH version: SSH-2.0-RebexSSH_5.0.8062.0
15:00:12.130 Debug SSH: Session 1: Remote SSH version: SSH-2.0-libssh2_1.10.0
15:00:12.135 Debug SSH: Session 1: Performing algorithm negotiation and key exchange.
15:00:12.207 Debug SSH: Session 1: Performing key exchange using curve25519-sha256 with ssh-rsa.
15:00:12.252 Debug SSH: Session 1: Cipher info: SSH 2.0, curve25519-sha256, ssh-rsa, aes128-ctr/aes128-ctr, hmac-sha2-256/hmac-sha2-256
15:00:12.258 Debug SSH: Session 1: Key exchange finished.
15:00:12.268 Debug SSH: Session 1: Performing authentication.
15:00:12.280 Debug SSH: Session 1: Starting authentication as 'tester' for 'ssh-connection'.
15:00:12.285 Info Server: Session 1: Authentication for 'tester' succeeded.
15:00:12.289 Debug SSH: Session 1: Authenticated as 'tester' for 'ssh-connection'.
15:00:12.298 Debug SSH: Session 1: Received SSH_MSG_CHANNEL_REQUEST: subsystem('sftp').
15:00:12.303 Debug Server: Session 1: Starting acv(1) subsystem.
15:00:12.314 Debug SFTP: Getting item info on '/': success.
15:00:12.338 Debug SFTP: Opening file '/example.txt' (Create, Write): success.
15:00:12.344 Debug SFTP: Closing file '/example.txt': success.
15:00:12.353 Info Server: Session 1: Closed connection from 10.0.0.42:52404.
15:00:12.356 Info SSH: Session 1: Connection close requested.
by (160 points)
Yes you were right!, I was trying with full path "C/Users/xxxx/Downloads/RebexTinySftpServer-Binaries-Latest/data", but it worked with some file name like "\t.txt".

Thank you!
by (144k points)
Yes, that explains it. Tiny SFTP server only exposes the "data" subfolder (by default), and from SFTP client's point of view that's the root directory.
...