paramiko.exec_command() not executing and returns "Extra params found in CLI"
<p>I am trying to ssh a server using Paramiko and execute a command. But the paramiko.exec_command() returns with an error.Why is this happening?</p>

<p>This is my Python script:</p>

<pre><code>import paramiko

ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.126.141.132', username='usrm', password='passwd')

stdin, stdout, stderr = ssh.exec_command("show chassis")

print(stdout.readlines())

ssh.close()
</code></pre>

<p>When executed it returns with this message:</p>

<blockquote>
  <p>['Extra params found in CLI, this is not supported, exiting the CLI session:\n']</p>
</blockquote>

<p>I am using Python 3.5.2 :: Anaconda 4.1.1 (64-bit) with Paramiko on Windows.</p>

<p>I have tried the commands manually and it is working.</p>

<p>Based on your latest comment:</p>

<blockquote>
  <p>I installed a Cygwin Terminal and SSH'd the server with the command...it came up with the <code>Extra params</code> error. Command I executed: <code>ssh usrm@10.126.141.132 "show chassis"</code>, Output: <code>No entry for terminal type "dumb"; using dumb terminal settings. Extra params found in CLI, this is not supported, exiting the CLI session:</code></p>
</blockquote>

<p>it sounds like the <code>usrm</code> account's <em>login shell</em> on the SSH server is not allowed to run commands in the non-interactive way. To solve the problem you have to use <code>invoke_shell()</code> like this:</p>

<pre><code>chan = ssh.invoke_shell()
chan.sendall('show chassis\r')
s = chan.recv(4096)
print s
</code></pre>

python python-3.x network-programming paramiko