314598340 发表于 2018-7-29 12:50:40

Ansible学习:(一)Ansible基础

1.生成密钥:  
# 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:
  
74:a2:fc:4d:0c:97:0a:a6:4f:e4:8a:e0:44:f5:4d:d0 root@test
  
The key's randomart image is:
  
+--[ RSA 2048]----+
  
|   . .o.         |
  
|. . oE   .   |
  
| .   .+.+ +      |
  
|.    * + B       |
  
|... = S o      |
  
|o. . + . o       |
  
| .. . . . .      |
  
|               |
  
|               |
  
+-----------------+
  
2.将公钥下发到被管理节点用户的.ssh目录
  
# ssh-copy-id -i /root/.ssh/id_rsa.pubroot@192.168.129.130
  
The authenticity of host '192.168.129.130 (192.168.129.130)' can't be established.
  
RSA key fingerprint is 0b:2d:68:5f:50:91:06:07:3c:2a:81:05:3c:c5:f9:2b.
  
Are you sure you want to continue connecting (yes/no)? yes
  
/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@192.168.129.130's password: ##输入被控端密码
  

  
Number of key(s) added: 1
  

  
Now try logging into the machine, with:   "ssh 'root@192.168.129.130'"
  
and check to make sure that only the key(s) you wanted were added.
  
3.验证无密码配置是否成功
  
# ssh root@192.168.129.130
  
Last login: Sun Apr9 21:32:33 2017 from 192.168.129.134
  
#
  
给其他被控节点下发公钥步骤同上,这里不做详细说明
页: [1]
查看完整版本: Ansible学习:(一)Ansible基础