第三章——ssh口令与秘钥认证
1.SSH密码认证
vim /etc/ansible/hosts
[webservers]
192.168.1.10:22 ansible_ssh_user=root ansible_ssh_pass=’123456’
192.168.1.11:22 ansible_ssh_user=root ansible_ssh_pass=’123456’
2.SSH秘钥对认证
[webservers]
192.168.1.10:22 ansible_ssh_user=root ansible_ssh_key=/root/.ssh/id_rsa
192.168.1.11:22 ansible_ssh_user=root
创建秘钥对
ssh-keygen] #直接回车,创建秘钥对
ls .ssh/
id_rsa id_rsa.pub know_hosts
ssh-copy-id root@192.168.0.13 #拷贝到目标主机
输入 yes 密码
ssh root@192.168.0.13 #免密登录

浙公网安备 33010602011771号