5_paramiko_SSHException Invalid requirement, parse error at
来源:互联网 发布:绘图纸用什么软件 编辑:程序博客网 时间:2024/06/15 06:45
不加sleep(0.5)会出现SSHException: Invalid requirement, parse error at ” ” “问题,原因暂时未知。
- 如果不使用多线程,则不会出现问题
- 使用多线程一定要sleep(0.2),也就是多个线程之间一定要有时间间隙
#!/usr/bin/env pythonimport paramikoimport threadingimport sysimport timedef ssh(host, user, cmd): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy( paramiko.AutoAddPolicy() ) pkey_file = '/Users/icq/.ssh/id_rsa' # key = paramiko.RSAKey.from_private_key_file( pkey_file, password='' ) key = paramiko.RSAKey.from_private_key_file( pkey_file, password='' ) try: ssh.connect( hostname=host, username=user, pkey=key, timeout=5 ) except: print 'connection has some problems...' return -1 stdin, stdout, stderr = ssh.exec_command( cmd ) stdout = stdout.read() stderr = stderr.read() if stdout: print '%s: %s' % (host, stdout), ssh.close() else: print '%s: %s' % (host, stderr), ssh.close()if __name__ == '__main__': hosts = ['192.168.31.114', '192.168.31.115', '192.168.31.116', '192.168.31.117'] try: cmd = sys.argv[1] except IndexError: print '%s follow a command must be' % __file__ sys.exit(-1) for host in hosts: t = threading.Thread( target=ssh, args=(host, 'root', 'uptime') ) t.start() time.sleep(0.5) #如果不加此行则会出现下面描述的异常 # ssh(host, 'root', 'uptime')执行结果如下,有时候就没有异常,有时候就有 ,我网在也找不到合适的结论,麻烦都是您帮忙看下,这个问题是什么原因导致的呢。192.168.31.116: 11:51:53 up 1:03, 1 user, load average: 0.07, 0.26, 0.18192.168.31.114: 11:51:53 up 1:03, 1 user, load average: 0.07, 0.26, 0.18192.168.31.115: 11:51:53 up 1:03, 1 user, load average: 0.07, 0.26, 0.18Exception in thread Thread-3:Traceback (most recent call last): File "/Users/icq/.pyenv/versions/2.7.13/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/Users/icq/.pyenv/versions/2.7.13/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "parallel.py", line 12, in ssh key = paramiko.RSAKey.from_private_key_file( pkey_file, password='' ) File "/Users/icq/.pyenv/versions/2.7.13/lib/python2.7/site-packages/paramiko/pkey.py", line 196, in from_private_key_file key = cls(filename=filename, password=password) File "/Users/icq/.pyenv/versions/2.7.13/lib/python2.7/site-packages/paramiko/rsakey.py", line 46, in __init__ self._from_private_key_file(filename, password) File "/Users/icq/.pyenv/versions/2.7.13/lib/python2.7/site-packages/paramiko/rsakey.py", line 174, in _from_private_key_file self._decode_key(data) File "/Users/icq/.pyenv/versions/2.7.13/lib/python2.7/site-packages/paramiko/rsakey.py", line 186, in _decode_key raise SSHException(str(e))SSHException: Invalid requirement, parse error at "''"192.168.31.117: 11:51:54 up 1:03, 1 user, load average: 0.07, 0.25, 0.18192.168.31.115: 11:51:54 up 1:03, 1 user, load average: 0.07, 0.25, 0.18192.168.31.114: 11:51:54 up 1:03, 1 user, load average: 0.07, 0.25, 0.18192.168.31.115: 11:51:55 up 1:03, 1 user, load average: 0.07, 0.25, 0.18192.168.31.116: 11:51:55 up 1:03, 1 user, load average: 0.07, 0.25, 0.18192.168.31.114: 11:51:55 up 1:03, 1 user, load average: 0.07, 0.25, 0.18192.168.31.117: 11:51:55 up 1:03, 1 user, load average: 0.07, 0.25, 0.18
阅读全文
0 0
- 5_paramiko_SSHException Invalid requirement, parse error at
- 错误 Parse error at ''
- 严重: Parse Fatal Error at line 154 column 33: Invalid byte 2 of 2-byte UTF-8 sequence.
- QT moc: Parse error at “std”
- Parse Fatal Error at line 5 column 89: 已经为元素 "web-app" 指定属性 "xmlns"。
- XML parse error: not well-formed (invalid token)
- XML parse error: not well-formed (invalid token)
- Qt+Boost编译出现Parse error at "BOOST_JOIN"
- Qt+Boost编译出现Parse error at "BOOST_JOIN"
- Fatal Error: Invalid Layout of java.lang.String at value
- MDK:test.axf: Error: L6630E: Invalid token start expected number or ( but found n at position 5 on l
- Invalid layout of java.lang.String at value Error occurred during initialization of VM Invalid layou
- 【SVN】关于 The OPTIONS request returned invalid XML in the response: XML parse error 的 解决方案
- Parse error: syntax error
- 严重: Parse error in application web.xml file at jndi:/localhost/userLS/WEB-INF/web.xml
- Parse Fatal Error at line 4 column 43: 已经为元素 "web-app" 指定属性 "xmlns"。
- tomcat 启动出错 Parse Fatal Error at line 1 column 1:Premature end of file
- Parse Fatal Error at line 4 column 43: 已经为元素 "web-app" 指定属性 "xmlns"。
- day10 指针、字符串字面值、字符数组
- 构造——洛谷 P1416 攻击火星
- 根据子网掩码计算最大主机数
- C++:STL标准入门汇总
- Failed to check the status of the service com.taotao.search.service.SearchItemSerivce. No provider a
- 5_paramiko_SSHException Invalid requirement, parse error at
- Android 自定义歌词滚动
- QT之MainWindow
- Wireshark使用教程 (快速掌握重点)
- 资源管理也能快如闪电!
- MySQL存储过程
- Log4j与ssh整合
- treefrog 之发布
- 仿京东防抖动菜单