zoukankan      html  css  js  c++  java
  • ubuntu上安装ansible

    1 在最新的ubuntu系统上安装ansible : sudo ape-get install ansible

    2 切换到root用户 生成ssh免密登陆

      ssh-keygen -t rsa

      ssh-copy-id -i /root/.ssh/id_rsa.pub root@ip(ip是被ansible管理的节点地址)

      

    root@pxy-p:/etc/ansible# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:AsNJM46Bt5GCyQtaNXQOik+hKDAD9hRQZkIuMz3I/1g root@pxy-p
    The key's randomart image is:
    +---[RSA 2048]----+
    |XB=XX .          |
    |%O@O O           |
    |%*B+* .          |
    |+*o. o           |
    |  .. E. S        |
    |    +  .         |
    |   . .           |
    |                 |
    |                 |
    +----[SHA256]-----+
    root@pxy-p:/etc/ansible# ssh-copy-id -i /root/.ssh/id_rsa.pub root@100.98.40.134
    /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    root@100.98.40.134's password: 
    
    Number of key(s) added: 1
    
    Now try logging into the machine, with:   "ssh 'root@100.98.40.134'"
    and check to make sure that only the key(s) you wanted were added.
    
    root@pxy-p:/etc/ansible# ssh 100.98.40.134
    Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.15.0-29-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
    6 个可升级软件包。
    0 个安全更新。
    
    Last login: Tue Oct 30 16:29:25 2018 from 100.98.40.167
    root@pxy-snow:~# exit
    注销
    Connection to 100.98.40.134 closed.
    root@pxy-p:/etc/ansible# 

    如果ssh 免秘钥登陆节点失败:

      

    解决方法:

    1) 以root身份,chmod +w /etc/ssh/sshd_config

    2) vi /etc/ssh/sshd_config

    3) 将PermitRootLogin no改成PermitRootLogin yes

    4) service sshd restart

  • 相关阅读:
    关于总线的总结
    我已经理解了并发和并行的区别
    关于CPU的一些基本知识总结
    shell生成指定长度的随机数
    进程、线程、协程、例程、过程的区别是什么?
    Perl输出带颜色行号或普通输出行
    Ruby数组(2):数组方法详细整理
    Linux find常用用法示例
    MariaDB官方手册翻译
    Ruby中to_s和to_str、to_i和to_int、to_a和to_ary、to_h和to_hash的解释说明
  • 原文地址:https://www.cnblogs.com/my-blogs-for-everone/p/9877863.html
Copyright © 2011-2022 走看看