【发布时间】:2013-08-30 09:22:50
【问题描述】:
我正在使用 paramiko 生成 ssh 连接,但我无法为所有机器生成 ssh 连接。我收到几台机器的错误:
No handlers could be found for logger "paramiko.transport"
而且我的代码很简单:
try:
tmp_ssh = paramiko.SSHClient()
tmp_ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
tmp_ssh.connect(tmp_ip, 22, tmp_user, tmp_pswd, timeout = 5)
tmp_res = ""
if type(tmp_cmd) == type([]):
for tmp_str in tmp_cmd:
tmp_str = tmp_str.strip()
if len(tmp_str) > 0:
tmp_in, tmp_out, tmp_err = tmp_ssh.exec_command(tmp_str)
tmp_ret = tmp_out.readlines()
tmp_res += "".join(tmp_ret)
else:
tmp_cmd = str(tmp_cmd)
tmp_str = tmp_cmd.strip()
if len(tmp_str) > 0:
tmp_in, tmp_out, tmp_err = tmp_ssh.exec_command(tmp_str)
tmp_ret = tmp_out.readlines()
tmp_res += "".join(tmp_ret)
tmp_ssh.close()
print tmp_res
except:
print "ERROR"
我在谷歌上搜索了几个解决此问题的建议(例如,https://github.com/newsapps/beeswithmachineguns/issues/17)并按照他们的建议尝试,但仍然无法解决。
你以前遇到过这个问题吗?你是怎么解决的?
ps。我也试试 ssh(https://pypi.python.org/pypi/ssh),也有同样的问题。
【问题讨论】: