Skip to main content

Wrapper for libssh C library.

Project description

Bindings for libssh C library.

License Latest Version

Installation

Currently only installation from source is provided. Binary wheels to follow.

To install from source, run the following:

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

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 is released as much as possible
  • Very low overhead thin wrapper
  • Object oriented - memory freed automatically and safely as objects are garbage collected by Python
  • Use Python semantics where applicable, such as context manager and iterator support for opening and reading from channels and SFTP file handles
  • Raise errors as Python exceptions

Download files

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

Files for ssh-python, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size ssh_python-0.3.0-cp27-cp27m-manylinux1_x86_64.whl (3.3 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size ssh_python-0.3.0-cp27-cp27mu-manylinux1_x86_64.whl (3.3 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size ssh_python-0.3.0-cp34-cp34m-manylinux1_x86_64.whl (3.4 MB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size ssh_python-0.3.0-cp35-cp35m-manylinux1_x86_64.whl (3.4 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size ssh_python-0.3.0-cp36-cp36m-manylinux1_x86_64.whl (3.4 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size ssh_python-0.3.0-cp37-cp37m-manylinux1_x86_64.whl (3.4 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size ssh-python-0.3.0.tar.gz (1.2 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page