fabric Q&A

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

修改之前的/etc/ssh/sshd_config

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 = {'root@10.12.136.181':'111111','root@10.12.136.180':'111111111'}

执行没有语法错误但是还是需要输入密码

修改方式:

env.passwords = {'root@10.12.136.181:22':'111111','root@10.12.136.180:22':'111111111'}

我是怎么解决的呢?很简单,代码开源,自己去跟代码,跟错误。偶哈哈哈


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值