libssh2_sftp_init(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 from libssh2_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 πŸŒˆπŸŽ€