Skip to content

Bindings for libssh C library.

License

LGPL-2.1, LGPL-2.1 licenses found

Licenses found

LGPL-2.1
LICENSE
LGPL-2.1
COPYING
Notifications You must be signed in to change notification settings

dyydj/ssh-python

Repository files navigation

ssh-python

Bindings for libssh C library.

LicenseLatest 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__ importprint_functionimportosimportpwdfromssh.sessionimportSessionfromsshimportoptionsUSERNAME=pwd.getpwuid(os.geteuid()).pw_nameHOST='localhost's=Session() s.options_set(options.HOST, HOST) s.connect() # Authenticate with agents.userauth_agent(USERNAME) chan=s.channel_new() chan.open_session() chan.request_exec('echo me') size, data=chan.read() whilesize>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

About

Bindings for libssh C library.

Resources

License

LGPL-2.1, LGPL-2.1 licenses found

Licenses found

LGPL-2.1
LICENSE
LGPL-2.1
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C83.0%
  • Python11.7%
  • CMake3.6%
  • C++1.3%
  • Shell0.3%
  • Objective-C0.1%