1.无法连通目标机执行命令
具体报错信息:
root@Server paramiko]# fab -f /opt/fabric/demo1.py get_host_name [10.136.18.76] Executing task 'get_host_name' [10.136.18.76] run: ls -l No handlers could be found for logger "paramiko.transport" Fatal error: Incompatible version (1.5 instead of 2.0) Underlying exception: Incompatible version (1.5 instead of 2.0) Aborting.
解决方式:
这个是由于目标机的/etc/ssh/sshd_config版本不一致的原因
摘自 fabric的github
"paramiko" is a combination of the esperanto words for "paranoid" and "friend". it's a module for python 2.6+ that implements the SSH2 protocol for secure (encrypted and authenticated) connections to remote machines. unlike SSL (aka TLS), SSH2 protocol does not require hierarchical
13 #Port 22 14 #modify to ssh localhost xbn 15 #Protocol 2 16 Protocol 1 17 Protocol 1 18 #modify end 19 #AddressFamily any 20 #ListenAddress 0.0.0.0 21 #ListenAddress ::
修改之后的/etc/ssh/sshd_config
13 #Port 22 14 #modify to ssh localhost xbn 15 #Protocol 2 16 Protocol 2,1 17 Protocol 2,1 18 #modify end 19 #AddressFamily any 20 #ListenAddress 0.0.0.0 21 #ListenAddress ::搞定了
2.env.passwords 不能起作用
具体的配置如下:
env.hosts = ['10.12.136.181','10.12.136.180'] env.user="root" env.passwords = {'[email protected]':'111111','[email protected]':'111111111'}
执行没有语法错误但是还是需要输入密码
修改方式:
env.passwords = {'[email protected]:22':'111111','[email protected]:22':'111111111'}
我是怎么解决的呢?很简单,代码开源,自己去跟代码,跟错误。偶哈哈哈