paramiko.exec_command() 未执行且 returns "Extra params found in CLI"

paramiko.exec_command() not executing and returns "Extra params found in CLI"

我正在尝试使用 Paramiko 连接服务器并执行命令。但是带有 error.Why 的 paramiko.exec_command() returns 会发生这种情况吗?

这是我的 Python 脚本:

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()

执行时 returns 显示此消息:

['Extra params found in CLI, this is not supported, exiting the CLI session:\n']

我在 Windows.

上使用 Python 3.5.2 :: Anaconda 4.1.1(64 位)和 Paramiko

我已经手动尝试了这些命令,它正在运行。

根据您的最新评论:

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

听起来 usrm 帐户的 登录 shell 在 SSH 服务器上不允许在非交互式中执行 运行 命令方法。要解决此问题,您必须像这样使用 invoke_shell()

chan = ssh.invoke_shell()
chan.sendall('show chassis\r')
s = chan.recv(4096)
print s