[root@manager ~]# yum info ansible Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.163.com Installed Packages Name : ansible Arch : noarch Version : 2.7.4 Release : 1.el7 Size : 60 M Repo : installed From repo : epel Summary : SSH-based configuration management, deployment, and task execution system URL : http://ansible.com License : GPLv3+ Description : Ansible is a radically simple model-driven configuration management, : multi-node deployment, and remote task execution system. Ansible works : over SSH and does not require any software or daemons to be installed : on remote nodes. Extension modules can be written in any language and : are transferred to managed machines automatically.
[root@manager ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)? y 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:qCPWwGHKyoJQnaI++CwqIEf4m570/43jlJsHbEVLkrA root@manager The key's randomart image is: +---[RSA 2048]----+ .. . . . .o o .= o E + . o*.o . o ++o ..S. X oo . +. B=+o+ .o. +=++ . ..=. +o= ...o*o. +----[SHA256]-----+
[root@manager ~]# ssh-copy-id 172.16.1.31 /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@172.16.1.31's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '172.16.1.31'" and check to make sure that only the key(s) you wanted were added. [root@manager ~]# ssh-copy-id 172.16.1.61 /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@172.16.1.61's password: Permission denied, please try again. root@172.16.1.61's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '172.16.1.61'" and check to make sure that only the key(s) you wanted were added.
# 测试免密登录 [root@manager ~]# ssh root@172.16.1.31 Last login: Wed Jan 9 00:29:17 2018 from 10.0.0.1 [root@nfs ~]#