Ansible免密码登陆
生活随笔
收集整理的這篇文章主要介紹了
Ansible免密码登陆
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
配置Linux主機無密碼訪問
生成秘鑰
ssh-keygen -t rsaGenerating 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:
73:80:07:fa:9a:0d:e0:0e:d1:c2:44:d2:d2:61:67:21 root@ansible
The key's randomart image is:
+--[ RSA 2048]----+
|o=E.+.. |
|=oo+ . o |
|ooo . . o |
| + . . . . |
|. . . . S . |
| o = o |
| . o . |
| |
| |
+-----------------+ 將管理機上生成的秘鑰發送到被管理機
ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.16.1.10
ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.16.1.10 測試是否不需要密碼直接執行任務
ansible test -a "date"172.16.1.10 | SUCCESS | rc=0 >>
Fri Apr 6 21:47:21 CST 2018172.16.1.11 | SUCCESS | rc=0 >>
Fri Apr 6 21:47:21 CST 2018 執行Ansible任務時的排錯
通過Ansible執行任務時代上-v參數,打開調試模式(加的v個數越多調試的輸出信息越多,最多4個v):
-v的情況下:
ansible test -a "date" -vUsing /etc/ansible/ansible.cfg as config file
172.16.1.11 | SUCCESS | rc=0 >>
Fri Apr 6 21:49:43 CST 2018172.16.1.10 | SUCCESS | rc=0 >>
Fri Apr 6 21:49:43 CST 2018 -vv的情況下:
ansible test -a "date" -vvansible 2.4.2.0config file = /etc/ansible/ansible.cfgconfigured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']ansible python module location = /usr/lib/python2.7/site-packages/ansibleexecutable location = /usr/bin/ansiblepython version = 2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
172.16.1.11 | SUCCESS | rc=0 >>
Fri Apr 6 21:49:47 CST 2018172.16.1.10 | SUCCESS | rc=0 >>
Fri Apr 6 21:49:47 CST 2018META: ran handlers
META: ran handlers
轉載于:https://www.cnblogs.com/jie-fang/p/10293182.html
總結
以上是生活随笔為你收集整理的Ansible免密码登陆的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 有个隐藏的大卖场带上特殊眼镜才能看见是什
- 下一篇: 无线鼠标多少钱?