1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """
20 I{Paramiko} (a combination of the esperanto words for "paranoid" and "friend")
21 is a module for python 2.5 or greater that implements the SSH2 protocol for
22 secure (encrypted and authenticated) connections to remote machines. Unlike
23 SSL (aka TLS), the SSH2 protocol does not require hierarchical certificates
24 signed by a powerful central authority. You may know SSH2 as the protocol that
25 replaced C{telnet} and C{rsh} for secure access to remote shells, but the
26 protocol also includes the ability to open arbitrary channels to remote
27 services across an encrypted tunnel. (This is how C{sftp} works, for example.)
28
29 The high-level client API starts with creation of an L{SSHClient} object.
30 For more direct control, pass a socket (or socket-like object) to a
31 L{Transport}, and use L{start_server <Transport.start_server>} or
32 L{start_client <Transport.start_client>} to negoatite
33 with the remote host as either a server or client. As a client, you are
34 responsible for authenticating using a password or private key, and checking
35 the server's host key. I{(Key signature and verification is done by paramiko,
36 but you will need to provide private keys and check that the content of a
37 public key matches what you expected to see.)} As a server, you are
38 responsible for deciding which users, passwords, and keys to allow, and what
39 kind of channels to allow.
40
41 Once you have finished, either side may request flow-controlled L{Channel}s to
42 the other side, which are python objects that act like sockets, but send and
43 receive data over the encrypted session.
44
45 Paramiko is written entirely in python (no C or platform-dependent code) and is
46 released under the GNU Lesser General Public License (LGPL).
47
48 Website: U{https://github.com/paramiko/paramiko/}
49 """
50
51 import sys
52
53 if sys.version_info < (2, 5):
54 raise RuntimeError('You need python 2.5+ for this module.')
55
56
57 __author__ = "Jeff Forcier <jeff@bitprophet.org>"
58 __version__ = "1.10.2"
59 __license__ = "GNU Lesser General Public License (LGPL)"
60
61
62 from transport import SecurityOptions, Transport
63 from client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy
64 from auth_handler import AuthHandler
65 from channel import Channel, ChannelFile
66 from ssh_exception import SSHException, PasswordRequiredException, \
67 BadAuthenticationType, ChannelException, BadHostKeyException, \
68 AuthenticationException, ProxyCommandFailure
69 from server import ServerInterface, SubsystemHandler, InteractiveQuery
70 from rsakey import RSAKey
71 from dsskey import DSSKey
72 from sftp import SFTPError, BaseSFTP
73 from sftp_client import SFTP, SFTPClient
74 from sftp_server import SFTPServer
75 from sftp_attr import SFTPAttributes
76 from sftp_handle import SFTPHandle
77 from sftp_si import SFTPServerInterface
78 from sftp_file import SFTPFile
79 from message import Message
80 from packet import Packetizer
81 from file import BufferedFile
82 from agent import Agent, AgentKey
83 from pkey import PKey
84 from hostkeys import HostKeys
85 from config import SSHConfig
86 from proxy import ProxyCommand
87
88
89 for c in locals().values():
90 if issubclass(type(c), type) or type(c).__name__ == 'classobj':
91
92 c.__module__ = __name__
93 del c
94
95 from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
96 OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_CONNECT_FAILED, \
97 OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE
98
99 from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \
100 SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED
101
102 from common import io_sleep
103
104 __all__ = [ 'Transport',
105 'SSHClient',
106 'MissingHostKeyPolicy',
107 'AutoAddPolicy',
108 'RejectPolicy',
109 'WarningPolicy',
110 'SecurityOptions',
111 'SubsystemHandler',
112 'Channel',
113 'PKey',
114 'RSAKey',
115 'DSSKey',
116 'Message',
117 'SSHException',
118 'AuthenticationException',
119 'PasswordRequiredException',
120 'BadAuthenticationType',
121 'ChannelException',
122 'BadHostKeyException',
123 'ProxyCommand',
124 'ProxyCommandFailure',
125 'SFTP',
126 'SFTPFile',
127 'SFTPHandle',
128 'SFTPClient',
129 'SFTPServer',
130 'SFTPError',
131 'SFTPAttributes',
132 'SFTPServerInterface',
133 'ServerInterface',
134 'BufferedFile',
135 'Agent',
136 'AgentKey',
137 'HostKeys',
138 'SSHConfig',
139 'util',
140 'io_sleep' ]
141