Skip to main content

libssh C library bindings for Python.

Project description

Bindings for libssh C library.

License Latest Version https://circleci.com/gh/ParallelSSH/ssh-python/tree/master.svg?style=shield https://img.shields.io/pypi/wheel/ssh-python.svg https://img.shields.io/pypi/pyversions/ssh-python.svg

Installation

Binary wheels are provided for Linux, OSX and Windows wheels to follow.

pip install ssh-python

Project is beta status.

Prerequisites

  • OpenSSL or gcrypt library and development headers

  • Optionally Zlib library and development headers for compression

Libssh source code is embedded in this project and will be built when installation is triggered per above instructions. Versions of libssh other than the one embedded in this project are not supported.

Quick Start

from __future__ import print_function

import os
import pwd

from ssh.session import Session
from ssh import options

# Linux only
USERNAME = pwd.getpwuid(os.geteuid()).pw_name
HOST = 'localhost'

s = Session()
s.options_set(options.HOST, HOST)
s.connect()

# Authenticate with agent
s.userauth_agent(USERNAME)

chan = s.channel_new()
chan.open_session()
chan.request_exec('echo me')
size, data = chan.read()
while size > 0:
    print(data.strip())
    size, data = chan.read()
chan.close()

Output:

me

Features

The library uses Cython based native code extensions as wrappers to libssh.

  • Thread safe - GIL released as much as possible

  • Very low overhead thin wrapper

  • Object oriented * Memory freed automatically and safely as objects are garbage collected by Python

  • Uses Python semantics where applicable * channel/file handle context manager support * channel/file handle iterator support

  • Raises low level C errors as Python exceptions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssh-python-0.4.0.post4.tar.gz (1.4 MB view hashes)

Uploaded Source

Built Distributions

ssh_python-0.4.0.post4-cp39-cp39-manylinux2010_x86_64.whl (6.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

ssh_python-0.4.0.post4-cp38-cp38-manylinux2010_x86_64.whl (6.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

ssh_python-0.4.0.post4-cp37-cp37m-manylinux2010_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

ssh_python-0.4.0.post4-cp36-cp36m-manylinux2010_x86_64.whl (6.8 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

ssh_python-0.4.0.post4-cp35-cp35m-manylinux2010_x86_64.whl (6.7 MB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

ssh_python-0.4.0.post4-cp27-cp27mu-manylinux2010_x86_64.whl (6.5 MB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

ssh_python-0.4.0.post4-cp27-cp27m-manylinux2010_x86_64.whl (6.5 MB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page