第三章——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  #免密登录

 

 

 

 

 

posted @ 2020-12-17 16:51  斐语  阅读(139)  评论(0)    收藏  举报