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
|
|
|
#
|
|
|
|
# This file is part of paramiko.
|
|
|
|
#
|
|
|
|
# Paramiko is free software; you can redistribute it and/or modify it under the
|
|
|
|
# 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.
|
|
|
|
#
|
2013-09-28 00:29:18 -04:00
|
|
|
# Paramiko is distributed 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
|
2004-06-10 14:12:00 -04:00
|
|
|
# along with Paramiko; 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
|
|
|
"""
|
2014-01-23 05:32:59 -05:00
|
|
|
Paramiko (a combination of the esperanto words for "paranoid" and "friend")
|
2013-02-03 14:52:11 -05:00
|
|
|
is a module for python 2.5 or greater that implements the SSH2 protocol for
|
2004-01-04 04:29:13 -05:00
|
|
|
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
|
2014-01-23 05:32:59 -05:00
|
|
|
replaced ``telnet`` and ``rsh`` for secure access to remote shells, but the
|
2004-01-04 04:29:13 -05:00
|
|
|
protocol also includes the ability to open arbitrary channels to remote
|
2014-01-23 05:32:59 -05:00
|
|
|
services across an encrypted tunnel. (This is how ``sftp`` works, for example.)
|
2004-01-04 04:29:13 -05:00
|
|
|
|
2014-01-23 05:32:59 -05:00
|
|
|
The high-level client API starts with creation of an :class:`SSHClient` object.
|
2006-05-10 21:33:13 -04:00
|
|
|
For more direct control, pass a socket (or socket-like object) to a
|
2014-01-23 05:32:59 -05:00
|
|
|
:class:`Transport`, and use :class:`start_server <Transport.start_server>` or
|
|
|
|
:class:`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
|
2014-01-23 05:32:59 -05:00
|
|
|
the server's host key. (Key signature and verification is done by paramiko,
|
2004-01-04 04:29:13 -05:00
|
|
|
but you will need to provide private keys and check that the content of a
|
2014-01-23 05:32:59 -05:00
|
|
|
public key matches what you expected to see.) As a server, you are
|
2004-01-04 04:29:13 -05:00
|
|
|
responsible for deciding which users, passwords, and keys to allow, and what
|
|
|
|
kind of channels to allow.
|
|
|
|
|
2014-01-23 05:32:59 -05:00
|
|
|
Once you have finished, either side may request flow-controlled :class:`channels <Channel>`
|
|
|
|
to the other side, which are python objects that act like sockets, but send and
|
2004-01-04 04:29:13 -05:00
|
|
|
receive data over the encrypted session.
|
|
|
|
|
|
|
|
Paramiko is written entirely in python (no C or platform-dependent code) and is
|
|
|
|
released under the GNU Lesser General Public License (LGPL).
|
|
|
|
|
2014-01-23 05:32:59 -05:00
|
|
|
Website: https://github.com/paramiko/paramiko/
|
2004-01-04 04:29:13 -05:00
|
|
|
"""
|
2003-12-26 21:03:44 -05:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2013-02-03 14:52:11 -05:00
|
|
|
if sys.version_info < (2, 5):
|
|
|
|
raise RuntimeError('You need python 2.5+ for this module.')
|
2003-12-26 21:03:44 -05:00
|
|
|
|
|
|
|
|
2012-09-23 17:28:34 -04:00
|
|
|
__author__ = "Jeff Forcier <jeff@bitprophet.org>"
|
2014-02-14 12:36:33 -05:00
|
|
|
__version__ = "1.10.6"
|
2013-09-27 17:26:28 -04:00
|
|
|
__version_info__ = tuple([ int(d) for d in __version__.split(".") ])
|
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, \
|
2012-11-06 02:09:52 -05:00
|
|
|
AuthenticationException, ProxyCommandFailure
|
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
|
2012-11-06 02:09:52 -05:00
|
|
|
from proxy import ProxyCommand
|
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
|
|
|
|
2012-01-17 15:10:57 -05:00
|
|
|
from common import io_sleep
|
|
|
|
|
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',
|
2012-11-06 02:09:52 -05:00
|
|
|
'ProxyCommand',
|
|
|
|
'ProxyCommandFailure',
|
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',
|
2012-01-17 15:10:57 -05:00
|
|
|
'util',
|
|
|
|
'io_sleep' ]
|