auth.yaml
- hosts: all gather_facts: false tasks: - name: deliver authorized_keys authorized_key: user: XXXXX key: "{{ lookup('file', '/home/XXXXX/.ssh/authorized_keys') }}" # 从本地authorized_keys文件读取公钥内容 state: present exclusive: no
运行yaml文件:ansible-playbook auth.yaml