You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+10-215
Original file line number
Diff line number
Diff line change
@@ -35,28 +35,17 @@ Binary wheel packages are provided for Linux, OSX and Windows, all Python versio
35
35
36
36
For from source installation instructions, including building against system provided libssh2, `see documentation <https://ssh2-python.readthedocs.io/en/latest/installation.html#installation-from-source>`_.
37
37
38
-
For creating native system packages for Centos/RedHat, Ubuntu, Debian and Fedora, see `instructions in the documentation <http://ssh2-python.readthedocs.io/en/latest/installation.html#system-binary-packages>`_.
39
-
40
-
41
38
Who Should Use This
42
39
___________________
43
40
44
-
Developers of bespoke SSH clients.
45
-
46
-
47
-
Who Should Not Use This
48
-
_______________________
49
-
50
-
Developers looking for ready made SSH clients.
51
-
52
-
This library is not an SSH client.
41
+
Most developers will want to use the `high level clients <https://parallel-ssh.readthedocs.io/en/latest/quickstart.html#single-host-client>`_
42
+
in `parallel-ssh <https://github.com/ParallelSSH/parallel-ssh>`_
43
+
based on this library.
53
44
54
-
Developers looking for high level easy to use clients based on this library should use `parallel-ssh <https://github.com/ParallelSSH/parallel-ssh>`_. It provides both `single <https://parallel-ssh.readthedocs.io/en/latest/native_single.html>`_ and `parallel <https://parallel-ssh.readthedocs.io/en/latest/native_parallel.html>`_ clients.
55
-
56
-
This library provides bindings to libssh2 and its API closely matches libssh2.
57
-
58
-
If the examples seem long, this is not the right library. Use `parallel-ssh <https://github.com/ParallelSSH/parallel-ssh>`_.
45
+
This library provides bindings to the low-level libssh2 C-API. It is *not* high level, nor easy to use. A *lot* of code
46
+
would need to be written to use this library that is already provided by `parallel-ssh`.
59
47
48
+
Use `parallel-ssh <https://github.com/ParallelSSH/parallel-ssh>`_ unless *really* sure using a C-API is what is wanted.
60
49
61
50
API Feature Set
62
51
________________
@@ -67,207 +56,13 @@ Complete example scripts for various operations can be found in the `examples di
67
56
68
57
In addition, as ``ssh2-python`` is a thin wrapper of ``libssh2`` with Python semantics, `its code examples <https://libssh2.org/examples/>`_ can be ported straight over to Python with only minimal changes.
69
58
70
-
71
-
Library Features
72
-
----------------
73
-
74
-
The library uses `Cython`_ based native code extensions as wrappers to ``libssh2``.
75
-
76
-
Extension features:
77
-
78
-
* Thread safe - GIL is released as much as possible. Note that libssh2 does not support sharing sessions across threads
79
-
* Very low overhead
80
-
* Super fast as a consequence of the excellent C library it uses and prodigious use of native code
81
-
* Object oriented - memory freed automatically and safely as objects are garbage collected by Python
82
-
* Use Python semantics where applicable, such as context manager and iterator support for opening and reading from SFTP file handles
83
-
* Raise errors as Python exceptions
84
-
* Provide access to ``libssh2`` error code definitions
85
-
86
-
87
-
Quick Start
59
+
Examples
88
60
_____________
89
61
90
-
Both byte and unicode strings are accepted as arguments and encoded appropriately. To change default encoding, ``utf-8``, change the value of ``ssh2.utils.ENCODING``. Output is always in byte strings.
91
-
92
-
See `Complete Example`_ for an example including socket connect.
93
-
94
-
Please use either the issue tracker for reporting issues with code or the `mail group`_ for discussion and questions.
95
-
96
-
Contributions are most welcome!
97
-
98
-
99
-
Authentication Methods
100
-
-------------------------
101
-
102
-
103
-
Connect and get available authentication methods.
104
-
105
-
106
-
.. code-block:: python
107
-
108
-
from__future__import print_function
109
-
110
-
from ssh2.session import Session
111
-
112
-
sock =<create and connect socket>
113
-
114
-
session = Session()
115
-
session.handshake(sock)
116
-
print(session.userauth_list())
117
-
118
-
119
-
Output will vary depending on SSH server configuration. For example:
Passphrase can be provided with the ``passphrase`` keyword param - see `API documentation <https://ssh2-python.readthedocs.io/en/latest/session.html#ssh2.session.Session.userauth_publickey_fromfile>`_.
181
-
182
-
183
-
Password Authentication
184
-
----------------------------
185
-
186
-
.. code-block:: python
187
-
188
-
session.userauth_password(
189
-
username, '<my password>')
190
-
191
-
SFTP Read
192
-
-----------
193
-
194
-
.. code-block:: python
195
-
196
-
from ssh2.sftp importLIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR
197
-
198
-
sftp = session.sftp_init()
199
-
with sftp.open(<remote file to read>,
200
-
LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR) as remote_fh, \
201
-
open(<local file to write>, 'wb') as local_fh:
202
-
for size, data in remote_fh:
203
-
local_fh.write(data)
204
-
205
-
206
-
Complete Example
207
-
__________________
208
-
209
-
A simple usage example looks very similar to ``libssh2`` `usage examples <https://www.libssh2.org/examples/>`_.
210
-
211
-
See `examples directory <https://github.com/ParallelSSH/ssh2-python/tree/master/examples>`_ for more complete example scripts.
212
-
213
-
As mentioned, ``ssh2-python`` is intentionally a thin wrapper over ``libssh2`` and directly maps most of its API.
214
-
215
-
Clients using this library can be much simpler to use than interfacing with the ``libssh2`` API directly.
0 commit comments