Skip to content
Bindings for libssh C library.
Branch: master
Clone or download
adelton and pkittenis Remove functions deprecated in latest libssh master. (Resolves #10)
Addressing
skipping 'ssh/session.c' Cython extension (up-to-date)
building 'ssh.session' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Ilibssh/include -I/usr/include/python3.7m -c ssh/session.c -o build/temp.linux-x86_64-3.7/ssh/session.o -O3
ssh/session.c: In function ‘__pyx_pf_3ssh_7session_7Session_46is_server_known’:
ssh/session.c:4782:9: warning: ‘ssh_is_server_known’ is deprecated [-Wdeprecated-declarations]
         __pyx_v_rc = ssh_is_server_known(__pyx_v_self->_session);
         ^~~~~~~~~~
In file included from ssh/session.c:569:
libssh/include/libssh/libssh.h:551:31: note: declared here
 SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session);
                               ^~~~~~~~~~~~~~~~~~~
ssh/session.c: In function ‘__pyx_pf_3ssh_7session_7Session_118write_knownhost’:
ssh/session.c:9577:9: warning: ‘ssh_write_knownhost’ is deprecated [-Wdeprecated-declarations]
         __pyx_v_rc = ssh_write_knownhost(__pyx_v_self->_session);
         ^~~~~~~~~~
In file included from ssh/session.c:569:
libssh/include/libssh/libssh.h:549:31: note: declared here
 SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session);
                               ^~~~~~~~~~~~~~~~~~~
ssh/session.c: In function ‘__pyx_pf_3ssh_7session_7Session_120dump_knownhost’:
ssh/session.c:9686:9: warning: ‘ssh_dump_knownhost’ is deprecated [-Wdeprecated-declarations]
         __pyx_v__known_host = ssh_dump_knownhost(__pyx_v_self->_session);
         ^~~~~~~~~~~~~~~~~~~
In file included from ssh/session.c:569:
libssh/include/libssh/libssh.h:550:33: note: declared here
 SSH_DEPRECATED LIBSSH_API char *ssh_dump_knownhost(ssh_session session);
                                 ^~~~~~~~~~~~~~~~~~
gcc -pthread -shared -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -g build/temp.linux-x86_64-3.7/ssh/session.o -L/root/ssh-python/src/src -L/usr/lib64 -Wl,--enable-new-dtags,-R$ORIGIN/. -lssh -lpython3.7m -o /root/ssh-python/ssh/session.cpython-37m-x86_64-linux-gnu.so
Latest commit b82ab39 Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ci
libssh Added latest libssh source. Updated setup.py Jun 27, 2018
ssh
tests Remove functions deprecated in latest libssh master. (Resolves #10) Mar 19, 2019
.appveyor.yml Initial libssh wrapper definitions and minimal implementation file. May 29, 2018
.gitignore
.gitmodules
.travis.yml Added manylinux binary wheel builds on travis-ci. Sep 23, 2018
COPYING
Changelog.rst
LICENSE Initial libssh wrapper definitions and minimal implementation file. May 29, 2018
MANIFEST.in Added SCP implementation. Sep 1, 2018
README.rst
_setup_libssh.py
requirements_dev.txt
setup.cfg Initial libssh wrapper definitions and minimal implementation file. May 29, 2018
setup.py
versioneer.py

README.rst

ssh-python

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
You can’t perform that action at this time.