libssh2_scp_send_ex(3)
π libssh2_scp_send_ex β bestie's guide to yeeting a file over SCP π
okay so this is a page from the libssh2 manual, and the function in question is libssh2_scp_send_ex(3). she's a classic, she's an icon, and she is also lowkey retired, which we'll get into. let's go π«Ά
β¨ SYNOPSIS β¨
#include <libssh2.h>
LIBSSH2_CHANNEL *
libssh2_scp_send_ex(LIBSSH2_SESSION *session, const char *path, int mode,
size_t size, long mtime, long atime);
look at her. five arguments. very main character energy. π
πΈ DESCRIPTION πΈ
so like. real talk first. this function has been deemed deprecated since libssh2 1.2.6. not me being the bearer of bad news π. the glow-up replacement is libssh2_scp_send64(3) β go check her out, she's the moment.
what this one does is send a file to the remote host via SCP. that's the whole vibe. β¨
and here's what each lil argument is giving:
sessionβ the Session instance, as returned bylibssh2_session_init_ex(3). your whole connection lives here basically.pathβ the full path and filename of the file to transfer to. i.e. the remote file name. not the local one, bestie, don't get it twisted πmodeβ the file access mode to create the file with.sizeβ the size of the file being transmitted. and okay this is the strict part: it must be known ahead of time precisely. like, exactly exactly. no vibes-based estimating here, she will notice. πmtimeβ the mtime to assign to the file being created.atimeβ the atime to assign to the file being created. and here's a cute lil trick: set this andmtimeboth to zero and you're telling the remote host "just use the current time bestie" β°β¨
π RETURN VALUE π
you get back a pointer to a newly allocated LIBSSH2_CHANNEL instance. fresh out the box, brand new, slay.
or, if things go sideways, you get NULL. that's the error signal. no in-between. π
π ERRORS π
here's the roster of ways this can go wrong, and what each one means:
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed. the malloc said "no ma'am".LIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket. the socket is not cooperating πLIBSSH2_ERROR_SCP_PROTOCOLβ yeah so this one is listed in the original with literally nothing after it. no explanation given, just the name. mysterious. iconic honestly. π΅οΈββοΈLIBSSH2_ERROR_EAGAINβ marked for non-blocking I/O but the call would block. she'd have to wait, and she simply will not. π ββοΈ
π¦ AVAILABILITY π¦
this function was marked deprecated in libssh2 1.2.6, because libssh2_scp_send64(3) has been introduced to replace this function. so like, she's still here, she still works, but the group chat has moved on. use the new one if you're starting fresh, fr fr. π
π SEE ALSO π
and that's the page, bestie!! you ate that. go forth and transfer files responsibly πβ¨
libssh2 0.15 Β· 1 Jun 2007 β yeah she's an elder, a vintage queen, and we respect her era ππ«Ά
π¦ 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