libssh2_session_handshake(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_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 from libssh2_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 0 on 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. πŸ’‹βœ¨πŸŽ€