author:head森 chenshell
date: 2018-08-13 10:28:34vim
1,ansible的安裝ssh
yum -y install epel-release測試
yum -y install ansible加密
2,配置ssh服務的免詢問(修改爲以下圖的形式)spa
vim /etc/ssh/ssh_configrest
service sshd restartcode
3,配置ansible的hosts文件blog
[root@bogon ~]# cat /etc/ansible/hosts [jack] 192.168.1.131 ansible_ssh_user=root ansible_ssh_pass=jack
4,測試密碼是否正確cmd
[root@bogon ~]# ansible jack -m ping 192.168.1.131 | SUCCESS => { "changed": false, "ping": "pong" }
當密碼不正確的時候:
ansible批量測試密碼:
ansible group -m raw -a 'date' -k # group爲/etc/ansible/hosts裏定義的列表名 輸入密碼:
5.1 添加ssh的免祕鑰登錄
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.200
5.2 配置本地的ansible的hosts文件: /etc/ansible/hosts
[group1]
192.168.0.200
ansible all -m ping