ansible不配ssh连接,用户密码登录

 1 yum install -y ansible
 2 
 3 wget https://nchc.dl.sourceforge.net/project/sshpass/sshpass/1.06/sshpass-1.06.tar.gz
 4 tar -xzf sshpass-1.06.tar.gz
 5 cd sshpass-1.06
 6 ./configure
 7 make
 8 make install
 9 
10 #主配置文件 /etc/ansible/ansible.cfg
11 #受控主机清单 /etc/ansible/hosts
12 vim /etc/ansible/hosts
13     [common]
14     [api]
15     192.168.0.100
16     [web]
17     192.168.0.200
18     [common:children]
19     api
20     web
21     [common:vars]
22     ansible_ssh_user=dev
23     ansible_ssh_pass=123456
24     ansible_ssh_port=2222
25 
26 ansible api -a "ls /tmp/"
27 #1、出现错误:
28     192.168.0.100 | UNREACHABLE! => {
29         "changed": false, 
30         "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /home/dev/.ansible/tmp/ansible-tmp-1545187395.08-192944776479178 `\" && echo ansible-tmp-1545187395.08-192944776479178=\"` echo /home/dev/.ansible/tmp/ansible-tmp-1545187395.08-192944776479178 `\" ), exited with result 1", 
31         "unreachable": true
32     }
33     #远程机子没有/home/dev/目录,补上即可
34 #2、出现错误:
35     192.168.0.100 | FAILED | rc=-1 >>
36     Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host.
37     #在/etc/ansible/ansible.cfg里打开 host_key_checking = False
38 
39 ansible api -a "ls /tmp/"
40     192.168.0.100 | SUCCESS | rc=0 >>
41     1.log
42     2.log

 

参考:

https://www.cnblogs.com/iois/p/6230800.html?tdsourcetag=s_pctim_aiomsg
http://blog.51cto.com/13859004/2173972
https://blog.csdn.net/wmj2004/article/details/53216002
https://www.cnblogs.com/ylqh/p/5902259.html
https://blog.csdn.net/longxibendi/article/details/46989735

转载于:https://www.cnblogs.com/chanAndy/p/10142849.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值