[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Libssh Python bindings


Hello list,
 
First off, thank you for the awesome library.
 
I wanted to let you know about new Python bindings that have written for libssh. Code is at https://github.com/ParallelSSH/ssh-python
 
It is beta status and currently lacks SCP and server implementations. Everything else is implemented though there may be bugs.
 
Only distributed as source code for now. Wheels - python binary packages that work across distributions - to follow.
 
To install:
 
pip install ssh-python
 
Quick example:
 
   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 = "">
   while size > 0:
       print(data.strip())
       size, data = "">
   chan.close()
 
 
The project contains libssh source code as-is and builds an embedded libssh to use when it is installed. The embedded version is the latest master branch and only that version is supported.
 
This is so it can keep track with latest features that are not yet released and also because supporting multiple versions with different functionality and header modifications is too time consuming for a single developer.
 
These bindings may not be fully usable yet for my own use case which is concurrent, non-blocking, use of SSH via an event loop system library in parallel-ssh but useful none the less. The capabilities, stability and speed of libssh are sorely needed in the python library ecosystem.
 
Have noticed that not all parts of libssh are fully usable in non-blocking mode, particularly connect and scp. Expect some patches where issues are found in future.
 
Relatedly, there is a patch for ssh_connect timing out in non-blocking mode that was reported a while back on this list, an issue I have also run into. Be happy to rebase and test it if it can be considered for merging.
 
Hope these bindings are useful to you as well.
 
Regards,
Panos

Follow-Ups:
Re: Libssh Python bindingsAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org