libssh  0.8.90
The SSH library
Chapter 8: Threads with libssh

How to use libssh with threads

libssh may be used in multithreaded applications, but under several conditions :

Initialization of threads

Since version 0.8.0, it is no longer necessary to call ssh_init()/ssh_finalize() if libssh is dynamically linked.

If libssh is statically linked, call ssh_init() before using any of libssh provided functions.

Using libpthread with libssh

Since version 0.8.0, libpthread is the default threads library used by libssh.

To use libpthread, simply link it to you application.

If you are using libssh statically linked, don't forget to call ssh_init() before using any of libssh provided functions (and ssh_finalize() in the end).

Using another threading library

Since version 0.8.0, libssh does not support custom threading libraries. The change makes sense since the newer versions for libcrypto (OpenSSL) and libgcrypt don't support custom threading libraries.

The default used threading library is libpthread. Alternatively, in Windows environment, CriticalSection based mutex control can be used.

If your system does not support libpthread nor CriticalSection based mutex control, unfortunately, you cannot use libssh in multithreaded scenarios.

Good luck !