标签:key bsp color use auth roo host 用户 code
1 ansible主机生成ssh密钥对
ssh-keygen 然后全部回车即可
2 指定推送ssh公钥的主机
vi /etc/ansible/hosts [push] 主机IP1 ansible_ssh_user="用户" ansible_ssh_pass="密码" ansible_ssh_port=22 主机IP2 ansible_ssh_user="用户" ansible_ssh_pass="密码" ansible_ssh_port=22
3 编写推送公钥的yaml剧本
vi /etc/ansible/ssh_push.yaml --- - hosts: push user: root tasks: - name: ssh-copy authorized_key: user=root key="{{ lookup(‘file‘, ‘/root/.ssh/id_rsa.pub‘) }}"
4 执行剧本推送公钥
ansible-playbook /etc/ansible/ssh_push.yaml
标签:key bsp color use auth roo host 用户 code
原文地址:https://www.cnblogs.com/gudanaimei/p/13239255.html