HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: //usr/share/doc/python27-paramiko-1.15.1/docs/api/client.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Client &mdash; Paramiko  documentation</title>
    
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Paramiko  documentation" href="../index.html" />
    <link rel="next" title="Message" href="message.html" />
    <link rel="prev" title="Channel" href="channel.html" />
   
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="message.html" title="Message"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="channel.html" title="Channel"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Paramiko  documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-paramiko.client">
<span id="client"></span><h1>Client<a class="headerlink" href="#module-paramiko.client" title="Permalink to this headline">¶</a></h1>
<p>SSH client &amp; key policies</p>
<dl class="class">
<dt id="paramiko.client.SSHClient">
<em class="property">class </em><tt class="descclassname">paramiko.client.</tt><tt class="descname">SSHClient</tt><a class="headerlink" href="#paramiko.client.SSHClient" title="Permalink to this definition">¶</a></dt>
<dd><p>A high-level representation of a session with an SSH server.  This class
wraps <a class="reference internal" href="transport.html#paramiko.transport.Transport" title="paramiko.transport.Transport"><tt class="xref py py-obj docutils literal"><span class="pre">Transport</span></tt></a>, <a class="reference internal" href="channel.html#paramiko.channel.Channel" title="paramiko.channel.Channel"><tt class="xref py py-obj docutils literal"><span class="pre">Channel</span></tt></a>, and <a class="reference internal" href="sftp.html#paramiko.sftp_client.SFTPClient" title="paramiko.sftp_client.SFTPClient"><tt class="xref py py-obj docutils literal"><span class="pre">SFTPClient</span></tt></a> to take care of most
aspects of authenticating and opening channels.  A typical use case is:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">client</span> <span class="o">=</span> <span class="n">SSHClient</span><span class="p">()</span>
<span class="n">client</span><span class="o">.</span><span class="n">load_system_host_keys</span><span class="p">()</span>
<span class="n">client</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="s">&#39;ssh.example.com&#39;</span><span class="p">)</span>
<span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">exec_command</span><span class="p">(</span><span class="s">&#39;ls -l&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>You may pass in explicit overrides for authentication and server host key
checking.  The default mechanism is to try to use local key files or an
SSH agent (if one is running).</p>
<p>Instances of this class may be used as context managers.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.6.</span></p>
</div>
<dl class="method">
<dt id="paramiko.client.SSHClient.__init__">
<tt class="descname">__init__</tt><big>(</big><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new SSHClient.</p>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.load_system_host_keys">
<tt class="descname">load_system_host_keys</tt><big>(</big><em>filename=None</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.load_system_host_keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Load host keys from a system (read-only) file.  Host keys read with
this method will not be saved back by <a class="reference internal" href="#paramiko.client.SSHClient.save_host_keys" title="paramiko.client.SSHClient.save_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">save_host_keys</span></tt></a>.</p>
<p>This method can be called multiple times.  Each new set of host keys
will be merged with the existing set (new replacing old if there are
conflicts).</p>
<p>If <tt class="docutils literal"><span class="pre">filename</span></tt> is left as <tt class="docutils literal"><span class="pre">None</span></tt>, an attempt will be made to read
keys from the user&#8217;s local &#8220;known hosts&#8221; file, as used by OpenSSH,
and no exception will be raised if the file can&#8217;t be read.  This is
probably only useful on posix.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the filename to read, or <tt class="docutils literal"><span class="pre">None</span></tt></td>
</tr>
<tr class="field-even field"><th class="field-name">Raises IOError:</th><td class="field-body">if a filename was provided and the file could not be read</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.load_host_keys">
<tt class="descname">load_host_keys</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.load_host_keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Load host keys from a local host-key file.  Host keys read with this
method will be checked after keys loaded via <a class="reference internal" href="#paramiko.client.SSHClient.load_system_host_keys" title="paramiko.client.SSHClient.load_system_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">load_system_host_keys</span></tt></a>,
but will be saved back by <a class="reference internal" href="#paramiko.client.SSHClient.save_host_keys" title="paramiko.client.SSHClient.save_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">save_host_keys</span></tt></a> (so they can be modified).
The missing host key policy <a class="reference internal" href="#paramiko.client.AutoAddPolicy" title="paramiko.client.AutoAddPolicy"><tt class="xref py py-obj docutils literal"><span class="pre">AutoAddPolicy</span></tt></a> adds keys to this set and
saves them, when connecting to a previously-unknown server.</p>
<p>This method can be called multiple times.  Each new set of host keys
will be merged with the existing set (new replacing old if there are
conflicts).  When automatically saving, the last hostname is used.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the filename to read</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises IOError:</th><td class="field-body">if the filename could not be read</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.save_host_keys">
<tt class="descname">save_host_keys</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.save_host_keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Save the host keys back to a file.  Only the host keys loaded with
<a class="reference internal" href="#paramiko.client.SSHClient.load_host_keys" title="paramiko.client.SSHClient.load_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">load_host_keys</span></tt></a> (plus any added directly) will be saved &#8211; not any
host keys loaded with <a class="reference internal" href="#paramiko.client.SSHClient.load_system_host_keys" title="paramiko.client.SSHClient.load_system_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">load_system_host_keys</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filename</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the filename to save to</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises IOError:</th><td class="field-body">if the file could not be written</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.get_host_keys">
<tt class="descname">get_host_keys</tt><big>(</big><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.get_host_keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the local <a class="reference internal" href="hostkeys.html#paramiko.hostkeys.HostKeys" title="paramiko.hostkeys.HostKeys"><tt class="xref py py-obj docutils literal"><span class="pre">HostKeys</span></tt></a> object.  This can be used to examine the
local host keys or change them.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the local host keys as a <a class="reference internal" href="hostkeys.html#paramiko.hostkeys.HostKeys" title="paramiko.hostkeys.HostKeys"><tt class="xref py py-obj docutils literal"><span class="pre">HostKeys</span></tt></a> object.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.set_log_channel">
<tt class="descname">set_log_channel</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.set_log_channel" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the channel for logging.  The default is <tt class="docutils literal"><span class="pre">&quot;paramiko.transport&quot;</span></tt>
but it can be set to anything you want.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; new channel name for logging</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.set_missing_host_key_policy">
<tt class="descname">set_missing_host_key_policy</tt><big>(</big><em>policy</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.set_missing_host_key_policy" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the policy to use when connecting to a server that doesn&#8217;t have a
host key in either the system or local <a class="reference internal" href="hostkeys.html#paramiko.hostkeys.HostKeys" title="paramiko.hostkeys.HostKeys"><tt class="xref py py-obj docutils literal"><span class="pre">HostKeys</span></tt></a> objects.  The
default policy is to reject all unknown servers (using <a class="reference internal" href="#paramiko.client.RejectPolicy" title="paramiko.client.RejectPolicy"><tt class="xref py py-obj docutils literal"><span class="pre">RejectPolicy</span></tt></a>).
You may substitute <a class="reference internal" href="#paramiko.client.AutoAddPolicy" title="paramiko.client.AutoAddPolicy"><tt class="xref py py-obj docutils literal"><span class="pre">AutoAddPolicy</span></tt></a> or write your own policy class.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>policy</strong> (<em>.MissingHostKeyPolicy</em>) &#8211; the policy to use when receiving a host key from a
previously-unknown server</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.connect">
<tt class="descname">connect</tt><big>(</big><em>hostname</em>, <em>port=22</em>, <em>username=None</em>, <em>password=None</em>, <em>pkey=None</em>, <em>key_filename=None</em>, <em>timeout=None</em>, <em>allow_agent=True</em>, <em>look_for_keys=True</em>, <em>compress=False</em>, <em>sock=None</em>, <em>gss_auth=False</em>, <em>gss_kex=False</em>, <em>gss_deleg_creds=True</em>, <em>gss_host=None</em>, <em>banner_timeout=None</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.connect" title="Permalink to this definition">¶</a></dt>
<dd><p>Connect to an SSH server and authenticate to it.  The server&#8217;s host key
is checked against the system host keys (see <a class="reference internal" href="#paramiko.client.SSHClient.load_system_host_keys" title="paramiko.client.SSHClient.load_system_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">load_system_host_keys</span></tt></a>)
and any local host keys (<a class="reference internal" href="#paramiko.client.SSHClient.load_host_keys" title="paramiko.client.SSHClient.load_host_keys"><tt class="xref py py-obj docutils literal"><span class="pre">load_host_keys</span></tt></a>).  If the server&#8217;s hostname
is not found in either set of host keys, the missing host key policy
is used (see <a class="reference internal" href="#paramiko.client.SSHClient.set_missing_host_key_policy" title="paramiko.client.SSHClient.set_missing_host_key_policy"><tt class="xref py py-obj docutils literal"><span class="pre">set_missing_host_key_policy</span></tt></a>).  The default policy is
to reject the key and raise an <a class="reference internal" href="ssh_exception.html#paramiko.ssh_exception.SSHException" title="paramiko.ssh_exception.SSHException"><tt class="xref py py-obj docutils literal"><span class="pre">SSHException</span></tt></a>.</p>
<p>Authentication is attempted in the following order of priority:</p>
<blockquote>
<div><ul class="simple">
<li>The <tt class="docutils literal"><span class="pre">pkey</span></tt> or <tt class="docutils literal"><span class="pre">key_filename</span></tt> passed in (if any)</li>
<li>Any key we can find through an SSH agent</li>
<li>Any &#8220;id_rsa&#8221;, &#8220;id_dsa&#8221; or &#8220;id_ecdsa&#8221; key discoverable in
<tt class="docutils literal"><span class="pre">~/.ssh/</span></tt></li>
<li>Plain username/password auth, if a password was given</li>
</ul>
</div></blockquote>
<p>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.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>hostname</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the server to connect to</li>
<li><strong>port</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; the server port to connect to</li>
<li><strong>username</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the username to authenticate as (defaults to the current local
username)</li>
<li><strong>password</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; a password to use for authentication or for unlocking a private key</li>
<li><strong>pkey</strong> (<em>.PKey</em>) &#8211; an optional private key to use for authentication</li>
<li><strong>key_filename</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the filename, or list of filenames, of optional private key(s) to
try for authentication</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#float" title="(in Python v2.6)"><em>float</em></a>) &#8211; an optional timeout (in seconds) for the TCP connect</li>
<li><strong>allow_agent</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#bool" title="(in Python v2.6)"><em>bool</em></a>) &#8211; set to False to disable connecting to the SSH agent</li>
<li><strong>look_for_keys</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#bool" title="(in Python v2.6)"><em>bool</em></a>) &#8211; set to False to disable searching for discoverable private key
files in <tt class="docutils literal"><span class="pre">~/.ssh/</span></tt></li>
<li><strong>compress</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#bool" title="(in Python v2.6)"><em>bool</em></a>) &#8211; set to True to turn on compression</li>
<li><strong>sock</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/socket.html#module-socket" title="(in Python v2.6)"><em>socket</em></a>) &#8211; an open socket or socket-like object (such as a <a class="reference internal" href="channel.html#paramiko.channel.Channel" title="paramiko.channel.Channel"><tt class="xref py py-obj docutils literal"><span class="pre">Channel</span></tt></a>) to use
for communication to the target host</li>
<li><strong>gss_auth</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#bool" title="(in Python v2.6)"><em>bool</em></a>) &#8211; <tt class="docutils literal"><span class="pre">True</span></tt> if you want to use GSS-API authentication</li>
<li><strong>gss_kex</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#bool" title="(in Python v2.6)"><em>bool</em></a>) &#8211; Perform GSS-API Key Exchange and user authentication</li>
<li><strong>gss_deleg_creds</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#bool" title="(in Python v2.6)"><em>bool</em></a>) &#8211; Delegate GSS-API client credentials or not</li>
<li><strong>gss_host</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; The targets name in the kerberos database. default: hostname</li>
<li><strong>banner_timeout</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#float" title="(in Python v2.6)"><em>float</em></a>) &#8211; an optional timeout (in seconds) to wait
for the SSH banner to be presented.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><ul class="first last simple">
<li><strong>BadHostKeyException</strong> &#8211; if the server&#8217;s host key could not be
verified</li>
<li><strong>AuthenticationException</strong> &#8211; if authentication failed</li>
<li><strong>SSHException</strong> &#8211; if there was any other error connecting or
establishing an SSH session</li>
<li><a class="reference external" href="http://docs.python.org/2.6/library/socket.html#socket.error" title="(in Python v2.6)"><strong>socket.error</strong></a> &#8211; if a socket error occurred while connecting</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 1.15: </span>Added the <tt class="docutils literal"><span class="pre">banner_timeout</span></tt>, <tt class="docutils literal"><span class="pre">gss_auth</span></tt>, <tt class="docutils literal"><span class="pre">gss_kex</span></tt>,
<tt class="docutils literal"><span class="pre">gss_deleg_creds</span></tt> and <tt class="docutils literal"><span class="pre">gss_host</span></tt> arguments.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.close">
<tt class="descname">close</tt><big>(</big><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close this SSHClient and its underlying <a class="reference internal" href="transport.html#paramiko.transport.Transport" title="paramiko.transport.Transport"><tt class="xref py py-obj docutils literal"><span class="pre">Transport</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.exec_command">
<tt class="descname">exec_command</tt><big>(</big><em>command</em>, <em>bufsize=-1</em>, <em>timeout=None</em>, <em>get_pty=False</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.exec_command" title="Permalink to this definition">¶</a></dt>
<dd><p>Execute a command on the SSH server.  A new <a class="reference internal" href="channel.html#paramiko.channel.Channel" title="paramiko.channel.Channel"><tt class="xref py py-obj docutils literal"><span class="pre">Channel</span></tt></a> is opened and
the requested command is executed.  The command&#8217;s input and output
streams are returned as Python <tt class="docutils literal"><span class="pre">file</span></tt>-like objects representing
stdin, stdout, and stderr.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>command</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the command to execute</li>
<li><strong>bufsize</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; interpreted the same way as by the built-in <tt class="docutils literal"><span class="pre">file()</span></tt> function in
Python</li>
<li><strong>timeout</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; set command&#8217;s channel timeout. See <tt class="xref py py-obj docutils literal"><span class="pre">Channel.settimeout</span></tt>.settimeout</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">the stdin, stdout, and stderr of the executing command, as a
3-tuple</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name" colspan="2">Raises SSHException:</th></tr>
<tr class="field-odd field"><td>&nbsp;</td><td class="field-body"><p class="first last">if the server fails to execute the command</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.invoke_shell">
<tt class="descname">invoke_shell</tt><big>(</big><em>term='vt100'</em>, <em>width=80</em>, <em>height=24</em>, <em>width_pixels=0</em>, <em>height_pixels=0</em><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.invoke_shell" title="Permalink to this definition">¶</a></dt>
<dd><p>Start an interactive shell session on the SSH server.  A new <a class="reference internal" href="channel.html#paramiko.channel.Channel" title="paramiko.channel.Channel"><tt class="xref py py-obj docutils literal"><span class="pre">Channel</span></tt></a>
is opened and connected to a pseudo-terminal using the requested
terminal type and size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>term</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#str" title="(in Python v2.6)"><em>str</em></a>) &#8211; the terminal type to emulate (for example, <tt class="docutils literal"><span class="pre">&quot;vt100&quot;</span></tt>)</li>
<li><strong>width</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; the width (in characters) of the terminal window</li>
<li><strong>height</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; the height (in characters) of the terminal window</li>
<li><strong>width_pixels</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; the width (in pixels) of the terminal window</li>
<li><strong>height_pixels</strong> (<a class="reference external" href="http://docs.python.org/2.6/library/functions.html#int" title="(in Python v2.6)"><em>int</em></a>) &#8211; the height (in pixels) of the terminal window</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">a new <a class="reference internal" href="channel.html#paramiko.channel.Channel" title="paramiko.channel.Channel"><tt class="xref py py-obj docutils literal"><span class="pre">Channel</span></tt></a> connected to the remote shell</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name" colspan="2">Raises SSHException:</th></tr>
<tr class="field-odd field"><td>&nbsp;</td><td class="field-body"><p class="first last">if the server fails to invoke a shell</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.open_sftp">
<tt class="descname">open_sftp</tt><big>(</big><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.open_sftp" title="Permalink to this definition">¶</a></dt>
<dd><p>Open an SFTP session on the SSH server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a new <a class="reference internal" href="sftp.html#paramiko.sftp_client.SFTPClient" title="paramiko.sftp_client.SFTPClient"><tt class="xref py py-obj docutils literal"><span class="pre">SFTPClient</span></tt></a> session object</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="paramiko.client.SSHClient.get_transport">
<tt class="descname">get_transport</tt><big>(</big><big>)</big><a class="headerlink" href="#paramiko.client.SSHClient.get_transport" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the underlying <a class="reference internal" href="transport.html#paramiko.transport.Transport" title="paramiko.transport.Transport"><tt class="xref py py-obj docutils literal"><span class="pre">Transport</span></tt></a> object for this SSH connection.
This can be used to perform lower-level tasks, like opening specific
kinds of channels.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">the <a class="reference internal" href="transport.html#paramiko.transport.Transport" title="paramiko.transport.Transport"><tt class="xref py py-obj docutils literal"><span class="pre">Transport</span></tt></a> for this connection</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="paramiko.client.MissingHostKeyPolicy">
<em class="property">class </em><tt class="descclassname">paramiko.client.</tt><tt class="descname">MissingHostKeyPolicy</tt><a class="headerlink" href="#paramiko.client.MissingHostKeyPolicy" title="Permalink to this definition">¶</a></dt>
<dd><p>Interface for defining the policy that <a class="reference internal" href="#paramiko.client.SSHClient" title="paramiko.client.SSHClient"><tt class="xref py py-obj docutils literal"><span class="pre">SSHClient</span></tt></a> should use when the
SSH server&#8217;s hostname is not in either the system host keys or the
application&#8217;s keys.  Pre-made classes implement policies for automatically
adding the key to the application&#8217;s <a class="reference internal" href="hostkeys.html#paramiko.hostkeys.HostKeys" title="paramiko.hostkeys.HostKeys"><tt class="xref py py-obj docutils literal"><span class="pre">HostKeys</span></tt></a> object (<a class="reference internal" href="#paramiko.client.AutoAddPolicy" title="paramiko.client.AutoAddPolicy"><tt class="xref py py-obj docutils literal"><span class="pre">AutoAddPolicy</span></tt></a>),
and for automatically rejecting the key (<a class="reference internal" href="#paramiko.client.RejectPolicy" title="paramiko.client.RejectPolicy"><tt class="xref py py-obj docutils literal"><span class="pre">RejectPolicy</span></tt></a>).</p>
<p>This function may be used to ask the user to verify the key, for example.</p>
<dl class="method">
<dt id="paramiko.client.MissingHostKeyPolicy.missing_host_key">
<tt class="descname">missing_host_key</tt><big>(</big><em>client</em>, <em>hostname</em>, <em>key</em><big>)</big><a class="headerlink" href="#paramiko.client.MissingHostKeyPolicy.missing_host_key" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when an <a class="reference internal" href="#paramiko.client.SSHClient" title="paramiko.client.SSHClient"><tt class="xref py py-obj docutils literal"><span class="pre">SSHClient</span></tt></a> receives a server key for a server that
isn&#8217;t in either the system or local <a class="reference internal" href="hostkeys.html#paramiko.hostkeys.HostKeys" title="paramiko.hostkeys.HostKeys"><tt class="xref py py-obj docutils literal"><span class="pre">HostKeys</span></tt></a> object.  To accept
the key, simply return.  To reject, raised an exception (which will
be passed to the calling application).</p>
</dd></dl>

<dl class="attribute">
<dt id="paramiko.client.MissingHostKeyPolicy.__weakref__">
<tt class="descname">__weakref__</tt><a class="headerlink" href="#paramiko.client.MissingHostKeyPolicy.__weakref__" title="Permalink to this definition">¶</a></dt>
<dd><p>list of weak references to the object (if defined)</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="paramiko.client.AutoAddPolicy">
<em class="property">class </em><tt class="descclassname">paramiko.client.</tt><tt class="descname">AutoAddPolicy</tt><a class="headerlink" href="#paramiko.client.AutoAddPolicy" title="Permalink to this definition">¶</a></dt>
<dd><p>Policy for automatically adding the hostname and new host key to the
local <a class="reference internal" href="hostkeys.html#paramiko.hostkeys.HostKeys" title="paramiko.hostkeys.HostKeys"><tt class="xref py py-obj docutils literal"><span class="pre">HostKeys</span></tt></a> object, and saving it.  This is used by <a class="reference internal" href="#paramiko.client.SSHClient" title="paramiko.client.SSHClient"><tt class="xref py py-obj docutils literal"><span class="pre">SSHClient</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="paramiko.client.RejectPolicy">
<em class="property">class </em><tt class="descclassname">paramiko.client.</tt><tt class="descname">RejectPolicy</tt><a class="headerlink" href="#paramiko.client.RejectPolicy" title="Permalink to this definition">¶</a></dt>
<dd><p>Policy for automatically rejecting the unknown hostname &amp; key.  This is
used by <a class="reference internal" href="#paramiko.client.SSHClient" title="paramiko.client.SSHClient"><tt class="xref py py-obj docutils literal"><span class="pre">SSHClient</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="paramiko.client.WarningPolicy">
<em class="property">class </em><tt class="descclassname">paramiko.client.</tt><tt class="descname">WarningPolicy</tt><a class="headerlink" href="#paramiko.client.WarningPolicy" title="Permalink to this definition">¶</a></dt>
<dd><p>Policy for logging a Python-style warning for an unknown host key, but
accepting it. This is used by <a class="reference internal" href="#paramiko.client.SSHClient" title="paramiko.client.SSHClient"><tt class="xref py py-obj docutils literal"><span class="pre">SSHClient</span></tt></a>.</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Paramiko</a></h1>



<p class="blurb">A Python implementation of SSHv2.</p>



<p>
<iframe src="http://ghbtns.com/github-btn.html?user=paramiko&repo=paramiko&type=watch&count=true&size=large"
  allowtransparency="true" frameborder="0" scrolling="0" width="200px" height="35px"></iframe>
</p>




    

<p>
<a href="https://travis-ci.org/paramiko/paramiko">
    <img
        alt="https://secure.travis-ci.org/paramiko/paramiko.png?branch=master"
        src="https://secure.travis-ci.org/paramiko/paramiko.png?branch=master"
    >
</a>
</p>
<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="channel.html">Channel</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Client</a></li>
<li class="toctree-l1"><a class="reference internal" href="message.html">Message</a></li>
<li class="toctree-l1"><a class="reference internal" href="packet.html">Packetizer</a></li>
<li class="toctree-l1"><a class="reference internal" href="transport.html">Transport</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="agent.html">SSH agents</a></li>
<li class="toctree-l1"><a class="reference internal" href="hostkeys.html">Host keys / <tt class="docutils literal"><span class="pre">known_hosts</span></tt> files</a></li>
<li class="toctree-l1"><a class="reference internal" href="keys.html">Key handling</a></li>
<li class="toctree-l1"><a class="reference internal" href="ssh_gss.html">GSS-API authentication</a></li>
<li class="toctree-l1"><a class="reference internal" href="kex_gss.html">GSS-API key exchange</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="proxy.html"><tt class="docutils literal"><span class="pre">ProxyCommand</span></tt> support</a></li>
<li class="toctree-l1"><a class="reference internal" href="server.html">Server implementation</a></li>
<li class="toctree-l1"><a class="reference internal" href="sftp.html">SFTP</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="buffered_pipe.html">Buffered pipes</a></li>
<li class="toctree-l1"><a class="reference internal" href="file.html">Buffered files</a></li>
<li class="toctree-l1"><a class="reference internal" href="pipe.html">Cross-platform pipe implementations</a></li>
<li class="toctree-l1"><a class="reference internal" href="ssh_exception.html">Exceptions</a></li>
</ul>


<hr />
<ul>
    
    <li class="toctree-l1"><a href="http://www.paramiko.org">Main website</a></li>
    
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
<h3>Donate</h3>
<p>
Consider supporting the authors on <a href="https://www.gratipay.com/">Gratipay</a>:
<script data-gratipay-username="bitprophet"
        data-gratipay-widget="button"
        src="//gttp.co/v1.js"></script>
</p>

        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2014 Jeff Forcier.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.2.2</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.6.1</a>
      
      |
      <a href="../_sources/api/client.txt"
          rel="nofollow">Page source</a></li>
    </div>

    

    
    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-18486793-2']);
      _gaq.push(['_setDomainName', 'none']);
      _gaq.push(['_setAllowLinker', true]);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>
    
  </body>
</html>