Package paramiko
[frames] | no frames]

Source Code for Package paramiko

  1  # Copyright (C) 2003-2011  Robey Pointer <robeypointer@gmail.com> 
  2  # 
  3  # This file is part of paramiko. 
  4  # 
  5  # Paramiko is free software; you can redistribute it and/or modify it under the 
  6  # terms of the GNU Lesser General Public License as published by the Free 
  7  # Software Foundation; either version 2.1 of the License, or (at your option) 
  8  # any later version. 
  9  # 
 10  # Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY 
 11  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
 12  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
 13  # details. 
 14  # 
 15  # You should have received a copy of the GNU Lesser General Public License 
 16  # along with Paramiko; if not, write to the Free Software Foundation, Inc., 
 17  # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. 
 18   
 19  """ 
 20  I{Paramiko} (a combination of the esperanto words for "paranoid" and "friend") 
 21  is a module for python 2.3 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{http://www.lag.net/paramiko/} 
 49   
 50  @version: 1.7.7.1 (George) 
 51  @author: Robey Pointer 
 52  @contact: robeypointer@gmail.com 
 53  @license: GNU Lesser General Public License (LGPL) 
 54  """ 
 55   
 56  import sys 
 57   
 58  if sys.version_info < (2, 2): 
 59      raise RuntimeError('You need python 2.2 for this module.') 
 60   
 61   
 62  __author__ = "Robey Pointer <robeypointer@gmail.com>" 
 63  __date__ = "21 May 2011" 
 64  __version__ = "1.7.7.1 (George)" 
 65  __version_info__ = (1, 7, 7, 1) 
 66  __license__ = "GNU Lesser General Public License (LGPL)" 
 67   
 68   
 69  from transport import SecurityOptions, Transport 
 70  from client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy 
 71  from auth_handler import AuthHandler 
 72  from channel import Channel, ChannelFile 
 73  from ssh_exception import SSHException, PasswordRequiredException, \ 
 74      BadAuthenticationType, ChannelException, BadHostKeyException, \ 
 75      AuthenticationException 
 76  from server import ServerInterface, SubsystemHandler, InteractiveQuery 
 77  from rsakey import RSAKey 
 78  from dsskey import DSSKey 
 79  from sftp import SFTPError, BaseSFTP 
 80  from sftp_client import SFTP, SFTPClient 
 81  from sftp_server import SFTPServer 
 82  from sftp_attr import SFTPAttributes 
 83  from sftp_handle import SFTPHandle 
 84  from sftp_si import SFTPServerInterface 
 85  from sftp_file import SFTPFile 
 86  from message import Message 
 87  from packet import Packetizer 
 88  from file import BufferedFile 
 89  from agent import Agent, AgentKey 
 90  from pkey import PKey 
 91  from hostkeys import HostKeys 
 92  from config import SSHConfig 
 93   
 94  # fix module names for epydoc 
 95  for c in locals().values(): 
 96      if issubclass(type(c), type) or type(c).__name__ == 'classobj': 
 97          # classobj for exceptions :/ 
 98          c.__module__ = __name__ 
 99  del c 
100   
101  from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \ 
102       OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED,  OPEN_FAILED_CONNECT_FAILED, \ 
103       OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE 
104   
105  from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \ 
106       SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED 
107   
108  __all__ = [ 'Transport', 
109              'SSHClient', 
110              'MissingHostKeyPolicy', 
111              'AutoAddPolicy', 
112              'RejectPolicy', 
113              'WarningPolicy', 
114              'SecurityOptions', 
115              'SubsystemHandler', 
116              'Channel', 
117              'PKey', 
118              'RSAKey', 
119              'DSSKey', 
120              'Message', 
121              'SSHException', 
122              'AuthenticationException', 
123              'PasswordRequiredException', 
124              'BadAuthenticationType', 
125              'ChannelException', 
126              'BadHostKeyException', 
127              'SFTP', 
128              'SFTPFile', 
129              'SFTPHandle', 
130              'SFTPClient', 
131              'SFTPServer', 
132              'SFTPError', 
133              'SFTPAttributes', 
134              'SFTPServerInterface', 
135              'ServerInterface', 
136              'BufferedFile', 
137              'Agent', 
138              'AgentKey', 
139              'HostKeys', 
140              'SSHConfig', 
141              'util' ] 
142