Michael Loutris wrote:
> All the libssh2 calls return success until libssh2_sftp_open(), where the
> sftp handle is returned NULL.
> Calling libssh2_sftp_last_error() returns error 2, LIBSSH2_FX_NO_SUCH_FILE.
> The flags and mode were left with the defaults:
> 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);
> As OpenSSH commands in a Windows command prompt succeeded in
> writing to the server, what settings might I be missing in libssh2?
Without a debug log (from the server) it's impossible to say what went
wrong. This is obvious, right? So we can only guess, which is not very
effective problem solving.
Since you're using Windows my guess is that the error is related to the
path that you have specified rather than the filename in the final
Every directory in the path must exist and you must use forward slash as
the directory separator in the SFTP protocol, never the Windows backslash.
OpenSSH built by Microsoft for Windows will possibly hide that for
your convenience, which would make it seem that the protocol accepts
different directory separators, but if my guess is correct then that's
essentially just Microsoft lying to you.
Received on 2020-10-17