批量配置ssh免密登陆

盛年不重来,一日难再晨,及时当勉励,岁月不待人。这篇文章主要讲述批量配置ssh免密登陆相关的知识,希望能为你提供帮助。
1、主控端安装ansible

yum -y install ansible

2、主控端生成ssh密钥
ssh-keygen -t rsa
# 默认回车即可

3、主控端配置ansible
配置hosts
vi /etc/ansible/hosts
[ssh]
192.168.94.1[38:39]

[ssh:vars]
ansible_ssh_pass=Asdf1234

编写pakybook
vi /etc/ansible/ssh.yaml
- hosts: ssh
user: root
tasks:
- name: ssh-copy
authorized_key: user=root key=" lookup(file, /root/.ssh/id_rsa.pub) "

执行playbook
ansible-playbook ssh.yaml

验证
ansible ssh -mshell -a "hostname"

【批量配置ssh免密登陆】


    推荐阅读