2011-05-23 03:40:37 -04:00
|
|
|
# Copyright (C) 2003-2011 Robey Pointer <robeypointer@gmail.com>
|
2004-01-04 05:26:00 -05:00
|
|
|
#
|
2011-10-23 03:00:43 -04:00
|
|
|
# This file is part of ssh.
|
2004-01-04 05:26:00 -05:00
|
|
|
#
|
2011-10-23 03:00:43 -04:00
|
|
|
# 'ssh' is free software; you can redistribute it and/or modify it under the
|
2004-01-04 05:26:00 -05:00
|
|
|
# terms of the GNU Lesser General Public License as published by the Free
|
|
|
|
# Software Foundation; either version 2.1 of the License, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
2011-10-23 03:00:43 -04:00
|
|
|
# 'ssh' is distrubuted in the hope that it will be useful, but WITHOUT ANY
|
2004-01-04 05:26:00 -05:00
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
2011-10-23 03:00:43 -04:00
|
|
|
# along with 'ssh'; if not, write to the Free Software Foundation, Inc.,
|
2004-01-04 05:26:00 -05:00
|
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
|
|
|
|
2004-01-04 04:29:13 -05:00
|
|
|
"""
|
2011-10-23 03:00:43 -04:00
|
|
|
I{'ssh'} (a combination of the esperanto words for "paranoid" and "friend")
|
2004-01-04 04:29:13 -05:00
|
|
|
is a module for python 2.3 or greater that implements the SSH2 protocol for
|
|
|
|
secure (encrypted and authenticated) connections to remote machines. Unlike
|
2010-04-25 20:05:06 -04:00
|
|
|
SSL (aka TLS), the SSH2 protocol does not require hierarchical certificates
|
2004-01-04 04:29:13 -05:00
|
|
|
signed by a powerful central authority. You may know SSH2 as the protocol that
|
|
|
|
replaced C{telnet} and C{rsh} for secure access to remote shells, but the
|
|
|
|
protocol also includes the ability to open arbitrary channels to remote
|
|
|
|
services across an encrypted tunnel. (This is how C{sftp} works, for example.)
|
|
|
|
|
2006-05-10 21:33:13 -04:00
|
|
|
The high-level client API starts with creation of an L{SSHClient} object.
|
|
|
|
For more direct control, pass a socket (or socket-like object) to a
|
|
|
|
L{Transport}, and use L{start_server <Transport.start_server>} or
|
2005-08-09 03:40:07 -04:00
|
|
|
L{start_client <Transport.start_client>} to negoatite
|
2004-01-04 04:29:13 -05:00
|
|
|
with the remote host as either a server or client. As a client, you are
|
|
|
|
responsible for authenticating using a password or private key, and checking
|
2011-10-23 03:00:43 -04:00
|
|
|
the server's host key. I{(Key signature and verification is done by ssh,
|
2004-01-04 04:29:13 -05:00
|
|
|
but you will need to provide private keys and check that the content of a
|
|
|
|
public key matches what you expected to see.)} As a server, you are
|
|
|
|
responsible for deciding which users, passwords, and keys to allow, and what
|
|
|
|
kind of channels to allow.
|
|
|
|
|
|
|
|
Once you have finished, either side may request flow-controlled L{Channel}s to
|
|
|
|
the other side, which are python objects that act like sockets, but send and
|
|
|
|
receive data over the encrypted session.
|
|
|
|
|
2011-10-23 03:00:43 -04:00
|
|
|
'ssh' is written entirely in python (no C or platform-dependent code) and is
|
2004-01-04 04:29:13 -05:00
|
|
|
released under the GNU Lesser General Public License (LGPL).
|
|
|
|
|
2011-10-23 03:00:43 -04:00
|
|
|
Website: U{http://www.lag.net/ssh/}
|
2004-01-04 04:29:13 -05:00
|
|
|
|
2011-05-23 16:49:47 -04:00
|
|
|
@version: 1.7.7.1 (George)
|
2004-01-04 04:29:13 -05:00
|
|
|
@author: Robey Pointer
|
2009-07-19 22:45:02 -04:00
|
|
|
@contact: robeypointer@gmail.com
|
2004-01-04 04:29:13 -05:00
|
|
|
@license: GNU Lesser General Public License (LGPL)
|
|
|
|
"""
|
2003-12-26 21:03:44 -05:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2004-04-06 04:16:02 -04:00
|
|
|
if sys.version_info < (2, 2):
|
|
|
|
raise RuntimeError('You need python 2.2 for this module.')
|
2003-12-26 21:03:44 -05:00
|
|
|
|
|
|
|
|
2009-07-19 22:45:02 -04:00
|
|
|
__author__ = "Robey Pointer <robeypointer@gmail.com>"
|
2011-05-23 03:40:37 -04:00
|
|
|
__date__ = "21 May 2011"
|
2011-05-23 16:49:47 -04:00
|
|
|
__version__ = "1.7.7.1 (George)"
|
|
|
|
__version_info__ = (1, 7, 7, 1)
|
2004-01-04 04:29:13 -05:00
|
|
|
__license__ = "GNU Lesser General Public License (LGPL)"
|
|
|
|
|
|
|
|
|
2010-08-02 18:13:08 -04:00
|
|
|
from transport import SecurityOptions, Transport
|
2008-02-19 02:47:36 -05:00
|
|
|
from client import SSHClient, MissingHostKeyPolicy, AutoAddPolicy, RejectPolicy, WarningPolicy
|
2005-08-09 03:40:07 -04:00
|
|
|
from auth_handler import AuthHandler
|
2005-08-09 02:30:59 -04:00
|
|
|
from channel import Channel, ChannelFile
|
2006-05-09 12:45:49 -04:00
|
|
|
from ssh_exception import SSHException, PasswordRequiredException, \
|
|
|
|
BadAuthenticationType, ChannelException, BadHostKeyException, \
|
|
|
|
AuthenticationException
|
2005-09-27 00:03:27 -04:00
|
|
|
from server import ServerInterface, SubsystemHandler, InteractiveQuery
|
2005-08-09 02:30:59 -04:00
|
|
|
from rsakey import RSAKey
|
|
|
|
from dsskey import DSSKey
|
|
|
|
from sftp import SFTPError, BaseSFTP
|
|
|
|
from sftp_client import SFTP, SFTPClient
|
|
|
|
from sftp_server import SFTPServer
|
|
|
|
from sftp_attr import SFTPAttributes
|
|
|
|
from sftp_handle import SFTPHandle
|
|
|
|
from sftp_si import SFTPServerInterface
|
|
|
|
from sftp_file import SFTPFile
|
|
|
|
from message import Message
|
|
|
|
from packet import Packetizer
|
|
|
|
from file import BufferedFile
|
|
|
|
from agent import Agent, AgentKey
|
|
|
|
from pkey import PKey
|
2006-02-19 19:35:13 -05:00
|
|
|
from hostkeys import HostKeys
|
2006-05-07 20:52:24 -04:00
|
|
|
from config import SSHConfig
|
2005-08-09 02:30:59 -04:00
|
|
|
|
|
|
|
# fix module names for epydoc
|
2006-09-07 21:55:16 -04:00
|
|
|
for c in locals().values():
|
|
|
|
if issubclass(type(c), type) or type(c).__name__ == 'classobj':
|
|
|
|
# classobj for exceptions :/
|
|
|
|
c.__module__ = __name__
|
2007-03-26 03:58:19 -04:00
|
|
|
del c
|
2004-01-04 04:29:13 -05:00
|
|
|
|
2004-09-03 18:39:20 -04:00
|
|
|
from common import AUTH_SUCCESSFUL, AUTH_PARTIALLY_SUCCESSFUL, AUTH_FAILED, \
|
|
|
|
OPEN_SUCCEEDED, OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED, OPEN_FAILED_CONNECT_FAILED, \
|
|
|
|
OPEN_FAILED_UNKNOWN_CHANNEL_TYPE, OPEN_FAILED_RESOURCE_SHORTAGE
|
2004-01-04 04:29:13 -05:00
|
|
|
|
2004-11-06 21:17:18 -05:00
|
|
|
from sftp import SFTP_OK, SFTP_EOF, SFTP_NO_SUCH_FILE, SFTP_PERMISSION_DENIED, SFTP_FAILURE, \
|
|
|
|
SFTP_BAD_MESSAGE, SFTP_NO_CONNECTION, SFTP_CONNECTION_LOST, SFTP_OP_UNSUPPORTED
|
2004-09-25 17:58:11 -04:00
|
|
|
|
2004-01-04 04:29:13 -05:00
|
|
|
__all__ = [ 'Transport',
|
2006-04-23 21:11:26 -04:00
|
|
|
'SSHClient',
|
|
|
|
'MissingHostKeyPolicy',
|
|
|
|
'AutoAddPolicy',
|
2006-08-13 15:35:46 -04:00
|
|
|
'RejectPolicy',
|
2008-02-19 02:47:36 -05:00
|
|
|
'WarningPolicy',
|
2004-08-30 16:22:10 -04:00
|
|
|
'SecurityOptions',
|
2004-09-05 03:44:03 -04:00
|
|
|
'SubsystemHandler',
|
2004-01-04 04:29:13 -05:00
|
|
|
'Channel',
|
2007-03-26 03:58:19 -04:00
|
|
|
'PKey',
|
2004-01-04 04:29:13 -05:00
|
|
|
'RSAKey',
|
|
|
|
'DSSKey',
|
2004-03-04 03:21:45 -05:00
|
|
|
'Message',
|
2004-01-04 04:29:13 -05:00
|
|
|
'SSHException',
|
2006-05-09 12:45:49 -04:00
|
|
|
'AuthenticationException',
|
2004-01-04 04:29:13 -05:00
|
|
|
'PasswordRequiredException',
|
2004-12-10 22:43:18 -05:00
|
|
|
'BadAuthenticationType',
|
2006-05-03 22:52:37 -04:00
|
|
|
'ChannelException',
|
2006-05-09 12:45:49 -04:00
|
|
|
'BadHostKeyException',
|
2004-03-04 03:21:45 -05:00
|
|
|
'SFTP',
|
2005-10-20 00:42:10 -04:00
|
|
|
'SFTPFile',
|
2004-11-22 02:27:21 -05:00
|
|
|
'SFTPHandle',
|
2004-09-05 03:44:03 -04:00
|
|
|
'SFTPClient',
|
2004-11-22 02:27:21 -05:00
|
|
|
'SFTPServer',
|
2004-09-05 03:44:03 -04:00
|
|
|
'SFTPError',
|
|
|
|
'SFTPAttributes',
|
2006-08-13 15:35:46 -04:00
|
|
|
'SFTPServerInterface',
|
2004-08-26 20:57:40 -04:00
|
|
|
'ServerInterface',
|
2004-09-25 17:58:11 -04:00
|
|
|
'BufferedFile',
|
2005-07-16 12:35:25 -04:00
|
|
|
'Agent',
|
2005-08-09 02:30:59 -04:00
|
|
|
'AgentKey',
|
2006-02-19 19:35:13 -05:00
|
|
|
'HostKeys',
|
2006-05-07 20:52:24 -04:00
|
|
|
'SSHConfig',
|
2004-01-04 04:29:13 -05:00
|
|
|
'util' ]
|