zoukankan      html  css  js  c++  java
  • Ansible配置免密登陆

    0x01:  把远程服务器的公钥来获取到本地

    #ssh-keyscan ip1 ip2 ip3 ip4 >> /root/.ssh/known_hosts
    

     完成后,/root/.ssh/known_hosts 多了许多内容

    0x02: 添加服务IP到 ansible 的 hosts 

    #cat >> /etc/ansible/hosts << EOF
    ip1
    ip2
    ip3
    ip4
    EOF
    #
    

    0x03: 添加免密登录(我的ROOT密码都一样,使用 -k 参数, 然后输入 root 密码)

    ansible all -m authorized_key -a "user=root state=present key="{{ lookup('file', '/root/.ssh/id_rsa.pub') }} "" -k
    

    0x04: 验证免密登陆

    #ansible all -m ping
    172.16.13.5 | SUCCESS => {
        "changed": false,
        "failed": false,
        "ping": "pong"
    }
    172.16.13.15 | SUCCESS => {
        "changed": false,
        "failed": false,
        "ping": "pong"
    }
    172.16.13.6 | SUCCESS => {
        "changed": false,
        "failed": false,
        "ping": "pong"
    }
    172.16.13.8 | SUCCESS => {
        "changed": false,
        "failed": false,
        "ping": "pong"
    }
    172.16.13.9 | SUCCESS => {
        "changed": false,
        "failed": false,
        "ping": "pong"
    }
    #
    

      

  • 相关阅读:
    C语言寒假大作战02
    C语言寒假大作战01
    学习总结
    C语言I作业11
    C语言I作业10
    C语言I博客作业09
    C语言I作业08
    实验五、单元测试
    实验四 代码审查
    UML 建模工具的安装与使用
  • 原文地址:https://www.cnblogs.com/fanlong0212/p/12185355.html
Copyright © 2011-2022 走看看