就是折腾
阅读 473
最后更新:2023/05/09/ 14:52:27
Ansible 安装与 SSH 认证配置
Ansible 安装
yum install ansible cowsay -y
ansible --version
SSH 密钥认证配置
Ad-Hoc
# 创建密钥
ssh-keygen -f /root/.ssh/id_rsa -P ""
# 禁用 SSH 密钥检查
sed -i 's/^#host_key_checking = False/host_key_checking = False/g' /etc/ansible/ansible.cfg
# 分发密钥
ansible all -m authorized_key -a "user=root state=present key='{{ lookup('file', '/root/.ssh/id_rsa.pub') }}'"
Playbook
- hosts: all
gather_facts: false
tasks:
- name: copy ssh key
authorized_key:
user: root
state: present
key: "{{ lookup('file', '/root/.ssh/id_rsa.pub') }}"
tags:
- sshkey
版权申明
本文系作者 @就是折腾 原创发布在就是折腾站点。未经许可,禁止转载。