libssh2_session_handshake(3)
π libssh2_session_handshake(3) β the moment you and the server finally say hi π
okay bestie, welcome to libssh2_session_handshake, aka the page where your lil session and a random remote host lock eyes across the room and start the whole "let's be friends" ritual. this is from the libssh2 manual, and honestly? it's the glow-up moment of every SSH connection. π¦
β¨ NAME β¨
libssh2_session_handshake β perform the SSH handshake
like, literally just that. the handshake. the vibe check between you and the server. π
πΈ SYNOPSIS πΈ
#include <libssh2.h>
int
libssh2_session_handshake(LIBSSH2_SESSION *session, libssh2_socket_t socket);
look at her. two args. one int return. so simple, so powerful. π
π DESCRIPTION π
sessionβ the session instance you got back fromlibssh2_session_init_ex(3). your main character. your baby. π«Άsocketβ a connected socket descriptor. usually it's a TCP connection, but ngl the protocol is flexible like that β it allows for any reliable transport, and the library will attempt to use any berkeley socket. so like, whatever socket you bring, she'll try. πββοΈ
and what does it do? it begins transport layer protocol negotiation with the connected host. that's the whole thing. that's the moment. it's giving first-date energy, but for cryptography. π₯
π RETURN VALUE π
- Returns
0on success. slay. β¨ - Returns negative on failure. not slay. π
π ERRORS π
ok so if it flops, here's the receipt. one of these is gonna come back at you:
LIBSSH2_ERROR_SOCKET_NONEβ the socket is invalid. bestie. that socket is not a socket. πLIBSSH2_ERROR_BANNER_SENDβ unable to send banner to remote host. the server didn't get your lil intro card. πLIBSSH2_ERROR_KEX_FAILUREβ encryption key exchange with the remote host failed. the key swap did NOT work out, it's giving situationship. πLIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket. the data said "no thank you". πLIBSSH2_ERROR_SOCKET_DISCONNECTβ the socket was disconnected. she left. she blocked you. πͺLIBSSH2_ERROR_PROTOβ an invalid SSH protocol response was received on the socket. the server is speaking nonsense and we are NOT fluent. πLIBSSH2_ERROR_EAGAINβ marked for non-blocking I/O but the call would block. you said "don't wait" and now she'd have to wait. awkward. β³
π AVAILABILITY π
added in 1.2.8. a vintage icon, honestly. iykyk. β
π SEE ALSO π
go read those too, bestie, they're the supporting cast. π
β οΈ real talk though β the negative return value means it did NOT work, so please check it before you start doing session things. no cap, check your return codes. π«‘
and that's the whole page, fr fr. this was the libssh2 manual, libssh2_session_handshake(3), dated 7 Oct 2010 β yeah she's old, she's iconic, she's still doing the handshake to this day. mwah. πβ¨π
π¦ 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