- SSH密码
vim /etc/ansible/hosts
[webservers]
192.168.10.251 ansible_ssh_user=root ansible_ssh_pass=123.com
192.168.10.252 ansible_ssh_user=root ansible_ssh_pass=123.com
192.168.10.253 ansible_ssh_user=root ansible_ssh_pass=123.com
- 密钥对认证
ssh-keygen
ssh-copy-id root@192.168.10.251
ssh-copy-id root@192.168.10.252
ssh-copy-id root@192.168.10.253
vim /etc/ansible/hosts
#可以不用再配置密码
[webservers]
192.168.10.251 ansible_ssh_user=root
192.168.10.252 ansible_ssh_user=root
192.168.10.253 ansible_ssh_user=root
#192.168.10.251 ansible_ssh_user=root ansible_ssh_key=/root/.ssh/id_rsa