Client info fields

This commit is contained in:
Jeff Forcier 2014-02-26 11:39:33 -08:00
parent f556c8f0ae
commit 01f365a3e1
1 changed files with 47 additions and 65 deletions

View File

@ -82,11 +82,10 @@ class SSHClient (object):
and no exception will be raised if the file can't be read. This is and no exception will be raised if the file can't be read. This is
probably only useful on posix. probably only useful on posix.
:param filename: the filename to read, or ``None`` :param str filename: the filename to read, or ``None``
:type filename: str
:raises IOError: if a filename was provided and the file could not be :raises IOError:
read if a filename was provided and the file could not be read
""" """
if filename is None: if filename is None:
# try the user's .ssh key file, and mask exceptions # try the user's .ssh key file, and mask exceptions
@ -110,8 +109,7 @@ class SSHClient (object):
will be merged with the existing set (new replacing old if there are will be merged with the existing set (new replacing old if there are
conflicts). When automatically saving, the last hostname is used. conflicts). When automatically saving, the last hostname is used.
:param filename: the filename to read :param str filename: the filename to read
:type filename: str
:raises IOError: if the filename could not be read :raises IOError: if the filename could not be read
""" """
@ -124,8 +122,7 @@ class SSHClient (object):
`load_host_keys` (plus any added directly) will be saved -- not any `load_host_keys` (plus any added directly) will be saved -- not any
host keys loaded with `load_system_host_keys`. host keys loaded with `load_system_host_keys`.
:param filename: the filename to save to :param str filename: the filename to save to
:type filename: str
:raises IOError: if the file could not be written :raises IOError: if the file could not be written
""" """
@ -146,8 +143,7 @@ class SSHClient (object):
Get the local `.HostKeys` object. This can be used to examine the Get the local `.HostKeys` object. This can be used to examine the
local host keys or change them. local host keys or change them.
:return: the local host keys :return: the local host keys as a `.HostKeys` object.
:rtype: `.HostKeys`
""" """
return self._host_keys return self._host_keys
@ -156,8 +152,7 @@ class SSHClient (object):
Set the channel for logging. The default is ``"paramiko.transport"`` Set the channel for logging. The default is ``"paramiko.transport"``
but it can be set to anything you want. but it can be set to anything you want.
:param name: new channel name for logging :param str name: new channel name for logging
:type name: str
""" """
self._log_channel = name self._log_channel = name
@ -168,9 +163,9 @@ class SSHClient (object):
default policy is to reject all unknown servers (using `.RejectPolicy`). default policy is to reject all unknown servers (using `.RejectPolicy`).
You may substitute `.AutoAddPolicy` or write your own policy class. You may substitute `.AutoAddPolicy` or write your own policy class.
:param policy: the policy to use when receiving a host key from a :param .MissingHostKeyPolicy policy:
the policy to use when receiving a host key from a
previously-unknown server previously-unknown server
:type policy: `.MissingHostKeyPolicy`
""" """
self._policy = policy self._policy = policy
@ -195,33 +190,26 @@ class SSHClient (object):
If a private key requires a password to unlock it, and a password is If a private key requires a password to unlock it, and a password is
passed in, that password will be used to attempt to unlock the key. passed in, that password will be used to attempt to unlock the key.
:param hostname: the server to connect to :param str hostname: the server to connect to
:type hostname: str :param int port: the server port to connect to
:param port: the server port to connect to :param str username:
:type port: int the username to authenticate as (defaults to the current local
:param username: the username to authenticate as (defaults to the username)
current local username) :param str password:
:type username: str a password to use for authentication or for unlocking a private key
:param password: a password to use for authentication or for unlocking :param .PKey pkey: an optional private key to use for authentication
a private key :param str key_filename:
:type password: str the filename, or list of filenames, of optional private key(s) to
:param pkey: an optional private key to use for authentication try for authentication
:type pkey: `.PKey` :param float timeout: an optional timeout (in seconds) for the TCP connect
:param key_filename: the filename, or list of filenames, of optional :param bool allow_agent: set to False to disable connecting to the SSH agent
private key(s) to try for authentication :param bool look_for_keys:
:type key_filename: str or list(str) set to False to disable searching for discoverable private key
:param timeout: an optional timeout (in seconds) for the TCP connect files in ``~/.ssh/``
:type timeout: float :param bool compress: set to True to turn on compression
:param allow_agent: set to False to disable connecting to the SSH agent :param socket sock:
:type allow_agent: bool an open socket or socket-like object (such as a `.Channel`) to use
:param look_for_keys: set to False to disable searching for discoverable for communication to the target host
private key files in ``~/.ssh/``
:type look_for_keys: bool
:param compress: set to True to turn on compression
:type compress: bool
:param sock: an open socket or socket-like object (such as a
`.Channel`) to use for communication to the target host
:type sock: socket
:raises BadHostKeyException: if the server's host key could not be :raises BadHostKeyException: if the server's host key could not be
verified verified
@ -304,14 +292,15 @@ class SSHClient (object):
streams are returned as Python ``file``-like objects representing streams are returned as Python ``file``-like objects representing
stdin, stdout, and stderr. stdin, stdout, and stderr.
:param command: the command to execute :param str command: the command to execute
:type command: str :param int bufsize:
:param bufsize: interpreted the same way as by the built-in ``file()`` function in Python interpreted the same way as by the built-in ``file()`` function in
:type bufsize: int Python
:param timeout: set command's channel timeout. See `Channel.settimeout`.settimeout :param int timeout:
:type timeout: int set command's channel timeout. See `Channel.settimeout`.settimeout
:return: the stdin, stdout, and stderr of the executing command :return:
:rtype: tuple(`.ChannelFile`, `.ChannelFile`, `.ChannelFile`) the stdin, stdout, and stderr of the executing command, as a
3-tuple
:raises SSHException: if the server fails to execute the command :raises SSHException: if the server fails to execute the command
""" """
@ -332,18 +321,13 @@ class SSHClient (object):
is opened and connected to a pseudo-terminal using the requested is opened and connected to a pseudo-terminal using the requested
terminal type and size. terminal type and size.
:param term: the terminal type to emulate (for example, ``"vt100"``) :param str term:
:type term: str the terminal type to emulate (for example, ``"vt100"``)
:param width: the width (in characters) of the terminal window :param int width: the width (in characters) of the terminal window
:type width: int :param int height: the height (in characters) of the terminal window
:param height: the height (in characters) of the terminal window :param int width_pixels: the width (in pixels) of the terminal window
:type height: int :param int height_pixels: the height (in pixels) of the terminal window
:param width_pixels: the width (in pixels) of the terminal window :return: a new `.Channel` connected to the remote shell
:type width_pixels: int
:param height_pixels: the height (in pixels) of the terminal window
:type height_pixels: int
:return: a new channel connected to the remote shell
:rtype: `.Channel`
:raises SSHException: if the server fails to invoke a shell :raises SSHException: if the server fails to invoke a shell
""" """
@ -356,8 +340,7 @@ class SSHClient (object):
""" """
Open an SFTP session on the SSH server. Open an SFTP session on the SSH server.
:return: a new SFTP session object :return: a new `.SFTPClient` session object
:rtype: `.SFTPClient`
""" """
return self._transport.open_sftp_client() return self._transport.open_sftp_client()
@ -367,8 +350,7 @@ class SSHClient (object):
This can be used to perform lower-level tasks, like opening specific This can be used to perform lower-level tasks, like opening specific
kinds of channels. kinds of channels.
:return: the Transport for this connection :return: the `.Transport` for this connection
:rtype: `.Transport`
""" """
return self._transport return self._transport