ansible-playbook: 实现ansible控制主机免密登录到其他远程主机

要想实现ansible控制主机免密登录到其他远程主机,则需要将ansible控制主机的主机密钥分发到其他远程主机上。

说明:ansible控制节点和被控制节点的系统版本如下,为什麽要说明系统版本时因为linux系统版本不同通过命令获取的结果有可能不正确,可以根据自己实际系统版本进行调整。

[root@myhost yml]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@myhost yml]# cat step00_sshKeyBossToOthers.yml

---
- hosts: new  #这个是hosts定义个主机组名字,如果是单台主机可以直接写地址,多个ip地址用都好隔开
  gather_facts: no 

  tasks: 
  - name: give the pub_keys of the boss_host to the remote hosts to let the boss_host can login the remote hosts without password.
    authorized_key: 
      user: root
      key: "{{lookup('file','/root/.ssh/id_rsa.pub')}}"
      state: present
      
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值