zoukankan      html  css  js  c++  java
  • Ansible ssh-key密钥认证配置

    对于被管理服务器做免密码登录设置

    1.在管理服务器生成ssh-key密钥

    #ssh-keygen  //生成秘钥

    root@hsz:/etc/ansible# ssh-keygen

    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:

    c5:5a:29:c4:d6:8d:f7:2c:46:f8:a3:c1:d8:e9:5b:06 root@hsz

    The key's randomart image is:

    +--[ RSA 2048]----+

    |       ... +     |

    |       .o.+.+    |

    |       ..+== o   |

    |        .=E = o  |

    |        S. = o   |

    |          o o    |

    |           +     |

    |          .      |

    |                 |

    +-----------------+

    #回车回车就行

    2.将秘钥拷贝到被管理服务器上

    #ssh-copy-id  -i ~/.ssh/id_rsa.pub -p 22 root@192.168.0.50

     

    #一般这样的命令就行,即被管理服务器的ssh端口默认

    #ssh-copy-id 192.168.0.50

    # 那么接下来就可以进行远程操作了(将被管理服务器ip加到清单的情况下)

    比如ping:

    [root@hsz ~]# ansible 192.168.0.50 -m ping 
    192.168.0.50 | SUCCESS => {
    "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
    }
  • 相关阅读:
    Java中的IO操作和缓冲区
    Java是否还能再辉煌十年?
    Java的字符串操作
    WordCount(Java实现)
    自我介绍+软工5问
    数据库系统第六章【关系数据理论】(B站视频)
    ini 配置文件读取程序(C语言)
    epoll介绍 实例
    Blizzardhash算法oneway hash
    pychartdir模块安装
  • 原文地址:https://www.cnblogs.com/hszstudypy/p/11520275.html
Copyright © 2011-2022 走看看