pcJc @ su d Z d d k Z d d k Td d k l Z d e f d YZ d e f d YZ d e i f d
YZ d S( sD
L{ServerInterface} is an interface to override for server support.
iN( t *( t utilt InteractiveQueryc B s) e Z d Z d d d Z e d Z RS( sP
A query (set of prompts) for a user during interactive authentication.
t c G s | | _ | | _ g | _ x] | D]U } t | t j p t | t j o | i | q" | i | d | d q" Wd S( s
Create a new interactive query to send to the client. The name and
instructions are optional, but are generally displayed to the end
user. A list of prompts may be included, or they may be added via
the L{add_prompt} method.
@param name: name of this query
@type name: str
@param instructions: user instructions (usually short) about this query
@type instructions: str
@param prompts: one or more authentication prompts
@type prompts: str
i i N( t namet instructionst promptst typet strt unicodet
add_prompt( t selfR R R t x( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyt __init__! s &c C s | i i | | f d S( s
Add a prompt to this query. The prompt should be a (reasonably short)
string. Multiple prompts can be added to the same query.
@param prompt: the user prompt
@type prompt: str
@param echo: C{True} (default) if the user's response should be echoed;
C{False} if not (for a password or similar)
@type echo: bool
N( R t append( R t promptt echo( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyR
8 s ( t __name__t
__module__t __doc__R
t TrueR
( ( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyR s t ServerInterfacec B s e Z d Z d Z d Z d Z d Z d Z d Z d Z d Z
d Z d
Z d Z
d Z d
Z d Z d Z d Z d Z RS( s
This class defines an interface for controlling the behavior of paramiko
in server mode.
Methods on this class are called from paramiko's primary thread, so you
shouldn't do too much work in them. (Certainly nothing that blocks or
sleeps.)
c C s t S( s%
Determine if a channel request of a given type will be granted, and
return C{OPEN_SUCCEEDED} or an error code. This method is
called in server mode when the client requests a channel, after
authentication is complete.
If you allow channel requests (and an ssh server that didn't would be
useless), you should also override some of the channel request methods
below, which are used to determine which services will be allowed on
a given channel:
- L{check_channel_pty_request}
- L{check_channel_shell_request}
- L{check_channel_subsystem_request}
- L{check_channel_window_change_request}
- L{check_channel_x11_request}
The C{chanid} parameter is a small number that uniquely identifies the
channel within a L{Transport}. A L{Channel} object is not created
unless this method returns C{OPEN_SUCCEEDED} -- once a
L{Channel} object is created, you can call L{Channel.get_id} to
retrieve the channel ID.
The return value should either be C{OPEN_SUCCEEDED} (or
C{0}) to allow the channel request, or one of the following error
codes to reject it:
- C{OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED}
- C{OPEN_FAILED_CONNECT_FAILED}
- C{OPEN_FAILED_UNKNOWN_CHANNEL_TYPE}
- C{OPEN_FAILED_RESOURCE_SHORTAGE}
The default implementation always returns
C{OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED}.
@param kind: the kind of channel the client would like to open
(usually C{"session"}).
@type kind: str
@param chanid: ID of the channel
@type chanid: int
@return: a success or failure code (listed above)
@rtype: int
( t' OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED( R t kindt chanid( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyt check_channel_requestP s *c C s d S( s
Return a list of authentication methods supported by the server.
This list is sent to clients attempting to authenticate, to inform them
of authentication methods that might be successful.
The "list" is actually a string of comma-separated names of types of
authentication. Possible values are C{"password"}, C{"publickey"},
and C{"none"}.
The default implementation always returns C{"password"}.
@param username: the username requesting authentication.
@type username: str
@return: a comma-separated list of authentication types
@rtype: str
t password( ( R t username( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyt get_allowed_auths| s c C s t S( s
Determine if a client may open channels with no (further)
authentication.
Return L{AUTH_FAILED} if the client must authenticate, or
L{AUTH_SUCCESSFUL} if it's okay for the client to not
authenticate.
The default implementation always returns L{AUTH_FAILED}.
@param username: the username of the client.
@type username: str
@return: L{AUTH_FAILED} if the authentication fails;
L{AUTH_SUCCESSFUL} if it succeeds.
@rtype: int
( t AUTH_FAILED( R R ( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyt check_auth_none s c C s t S( s\
Determine if a given username and password supplied by the client is
acceptable for use in authentication.
Return L{AUTH_FAILED} if the password is not accepted,
L{AUTH_SUCCESSFUL} if the password is accepted and completes
the authentication, or L{AUTH_PARTIALLY_SUCCESSFUL} if your
authentication is stateful, and this key is accepted for
authentication, but more authentication is required. (In this latter
case, L{get_allowed_auths} will be called to report to the client what
options it has for continuing the authentication.)
The default implementation always returns L{AUTH_FAILED}.
@param username: the username of the authenticating client.
@type username: str
@param password: the password given by the client.
@type password: str
@return: L{AUTH_FAILED} if the authentication fails;
L{AUTH_SUCCESSFUL} if it succeeds;
L{AUTH_PARTIALLY_SUCCESSFUL} if the password auth is
successful, but authentication must continue.
@rtype: int
( R ( R R R ( ( s3 /usr/lib/python2.6/site-packages/paramiko/server.pyt check_auth_password s c C s t S( s
Determine if a given key supplied by the client is acceptable for use
in authentication. You should override this method in server mode to
check the username and key and decide if you would accept a signature
made using this key.
Return L{AUTH_FAILED} if the key is not accepted,
L{AUTH_SUCCESSFUL} if the key is accepted and completes the
authentication, or L{AUTH_PARTIALLY_SUCCESSFUL} if your
authentication is stateful, and this password is accepted for
authentication, but more authentication is required. (In this latter
case, L{get_allowed_auths} will be called to report to the client what
options it has for continuing the authentication.)
Note that you don't have to actually verify any key signtature here.
If you're willing to accept the key, paramiko will do the work of
verifying the client's signature.
The default implementation always returns L{AUTH_FAILED}.
@param username: the username of the authenticating client
@type username: str
@param key: the key object provided by the client
@type key: L{PKey