libssh2_sftp_init(3)
π libssh2_sftp_init β open an SFTP channel for the given SSH session
okay bestie, this is a libssh2 page (the manual, the whole vibe), and today's main character is libssh2_sftp_init. let's get into it π¦
β¨ SYNOPSIS β¨
#include <libssh2.h>
#include <libssh2_sftp.h>
LIBSSH2_SFTP *
libssh2_sftp_init(LIBSSH2_SESSION *session);
πΈ DESCRIPTION πΈ
okay so first things first, the arg:
sessionβ the session instance you got back fromlibssh2_session_init_ex(3). that's your girl, she's already been introduced.
what this function does is open a channel and initialize the SFTP subsystem. and like, yes, the SFTP subsystem does ride over the same type of channel as the ones the Channel API exports β but no cap, the protocol itself implements its own unique binary packet protocol, and that little protocol has to be managed with the libssh2_sftp_*() family of functions. iykyk. you can't just freestyle it with channel calls.
and the moment your SFTP session is done? you must destroy it using libssh2_sftp_shutdown(3). not optional. it's giving β¨closureβ¨. periodt.
π RETURN VALUE π
you get back a pointer to the newly allocated SFTP instance, or NULL on failure. that's it, that's the deal π«Ά
π ERRORS π
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed. the vibes were off, memory said no πLIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket. the socket is not picking up what you're putting down πLIBSSH2_ERROR_SOCKET_TIMEOUTβ (no description given in the original, bestie β it's just sitting there, mysterious, iconic π)LIBSSH2_ERROR_SFTP_PROTOCOLβ an invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server. server said π«LIBSSH2_ERROR_EAGAINβ marked for non-blocking I/O but the call would block. so like, try again later, queen β
π SEE ALSO π
and that's the whole page fr fr π this one's from libssh2, version 0.15, dated 1 Jun 2007 β vintage, honestly. go slay your SFTP sessions bestie, and remember to shut them down ππ
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms