- 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
本文介绍如何使用Ansible进行批量服务器管理,通过SSH密码和密钥对两种方式进行远程连接配置。首先展示了如何在Ansible hosts文件中设置SSH密码进行身份验证,随后详细解释了如何生成SSH密钥对,并利用ssh-copy-id命令将公钥复制到目标服务器上,实现免密码登录,从而简化Ansible的使用流程。

1810

被折叠的 条评论
为什么被折叠?



