skillfed

ssh2-python

Bindings for libssh2 C library

ssh2-python v1.2.0.post1 317.0K downloads/30d#7,669 on PyPI235
Copyleft license LGPL-2.1-only Active released

What it is and what it does

ssh2-python is a thin Python wrapper around libssh2, the C library that implements the SSH2 protocol. It exposes the low-level libssh2 API directly to Python, allowing developers to perform SSH operations with minimal overhead. The package is distributed as pre-compiled binary wheels for major platforms and Python versions, with no runtime dependencies.

This is intentionally a low-level binding, not a high-level client library. It requires manual management of sessions, channels, and authentication, and substantial boilerplate code for common tasks. The documentation explicitly recommends that most developers use higher-level clients instead, which provide a simpler interface built on top of ssh2-python. Use ssh2-python only if you need direct control over libssh2 semantics or are building a specialized SSH tool.

Use it for:

  • Building a custom SSH client or server with fine-grained control over protocol behavior and performance.
  • Implementing SSH functionality in performance-critical applications where C-API overhead matters.
  • Porting existing libssh2 C code examples to Python with minimal changes.
  • Creating SSH automation tools that require low-level session and channel manipulation.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

ssh2-python provides Python bindings to libssh2, a low-level SSH2 protocol library, enabling direct access to SSH2 operations via C-API semantics.

Yes, if you need direct libssh2 bindings and understand the low-level API. No, if you want a simple SSH client—higher-level alternatives are recommended. The package is stable, actively maintained, has no known vulnerabilities, and offers good platform coverage. The LGPL-2.1-only license requires derivative works to be released under the same license, which may constrain proprietary use.

Install

ssh2-python on PyPI

pip

pip install ssh2-python

uv

uv add ssh2-python

poetry

poetry add ssh2-python

Installing ssh2-python

Before you install

Binary wheels are provided for Linux, macOS, and Windows across Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14, with no runtime dependencies. Install friction is medium due to the compiled nature of the bindings, but pre-built wheels eliminate build-time complexity for most platforms. Repository is actively maintained with a recent commit on 2026-06-12.

License in practice

Licensed under LGPL-2.1-only (copyleft). Any derivative work or modification must be released under the same license; static linking or bundling may trigger additional obligations depending on your distribution model.

Quickstart

pip install ssh2-python

import ssh2

session = ssh2.Session()
session.handshake('hostname')
session.userauth_password('user', 'password')
channel = session.open_session()
channel.execute('ls')
size, data = channel.read()
print(data.decode())

Requires a working SSH server to connect to; this is a low-level C-API wrapper and demands manual session and channel lifecycle management.

Verify before relying

  • Whether the package supports key-based authentication or only password authentication.
  • What the minimum Python version is (requires_python is unspecified in metadata).
  • Whether PyPy support is actively tested or only declared in classifiers.

Package facts

License LGPL-2.1-only (copyleft)
Python support not specified
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 306 days since the last release
Last repo commit
First released
Downloads 316,997/month — #7,669 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ssh2_python-1.2.0.post1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; ssh2_python-1.2.0.post1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; ssh2_python-1.2.0.post1-cp310-cp310-win_amd64.whl; ssh2_python-1.2.0.post1-cp311-cp311-macosx_12_0_arm64.whl; ssh2_python-1.2.0.post1-cp311-cp311-macosx_13_0_arm64.whl; ssh2_python-1.2.0.post1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; ssh2_python-1.2.0.post1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; ssh2_python-1.2.0.post1-cp311-cp311-win_amd64.whl; ssh2_python-1.2.0.post1-cp312-cp312-macosx_14_0_arm64.whl; ssh2_python-1.2.0.post1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; ssh2_python-1.2.0.post1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; ssh2_python-1.2.0.post1-cp312-cp312-win_amd64.whl; ssh2_python-1.2.0.post1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; ssh2_python-1.2.0.post1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; ssh2_python-1.2.0.post1-cp313-cp313-win_amd64.whl; ssh2_python-1.2.0.post1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; ssh2_python-1.2.0.post1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; ssh2_python-1.2.0.post1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; ssh2_python-1.2.0.post1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; ssh2_python-1.2.0.post1-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXOperating System :: POSIX :: BSDOperating System :: POSIX :: LinuxProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: NetworkingTopic :: System :: Shells

Tags

ssh2 protocol bindingslibssh2 python wrapperlow-level ssh libraryssh2 c api bindingsfast ssh implementation
ssh-protocolc-bindingslow-level-api

More Libraries packages