添加root免密
[xiaoxin@iZ2zee6df2m25shq6mfaw5Z ~]$ sudo vim /etc/ansible/hosts [d] 10.1.1.83 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.82 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.75 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.77 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.76 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.78 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.79 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.80 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.81 aansible_user=root ansible_ssh_pass="-1113" 10.1.1.84 aansible_user=root ansible_ssh_pass="-1113"
root账号生成密钥
[root@iZ2zee6df2m25shq6mfaw5Z ~]# 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:TI98mOG4nvwCJPKIV8UH+j3TdtgGL/QtPuWaXGGNGM8 root@iZ2zee6df2m25shq6mfaw5Z The key's randomart image is: +---[RSA 2048]----+ | ... | | .o . | | .. .o o . | |. . o. B O * * o | |.+ + o S B O E .| |o o . . = = = . | | . .. o o | | o.. . = | | +o. + | +----[SHA256]-----+
免密执行
[xiaoxin@iZ2zee6df2m25shq6mfaw5Z ansible]$ pwd /opt/ansible [xiaoxin@iZ2zee6df2m25shq6mfaw5Z ansible]$ ansible-playbook install_push.ssh.ymal --extra-vars "ansible_ssh_user=root" [WARNING]: While constructing a mapping from /opt/ansible/install_push.ssh.ymal, line 2, column 3, found a duplicate dict key (tasks). Using last defined value only. PLAY [d] ************************************************************************************************************************* TASK [Gathering Facts] *********************************************************************************************************** ok: [10.1.1.82] ok: [10.1.1.83] ok: [10.1.1.76] ok: [10.1.1.75] ok: [10.1.1.77] ok: [10.1.1.78] ok: [10.1.1.79] ok: [10.1.1.81] ok: [10.1.1.80] TASK [copy sudo文件 remote] ******************************************************************************************************** changed: [10.1.1.83] changed: [10.1.1.76] changed: [10.1.1.82] changed: [10.1.1.75] changed: [10.1.1.77] changed: [10.1.1.78] changed: [10.1.1.79] changed: [10.1.1.80] changed: [10.1.1.81] PLAY RECAP *********************************************************************************************************************** 10.1.1.75 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.76 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.77 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.78 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.79 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.80 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.81 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.82 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 10.1.1.83 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
继续阅读
- 我的QQ
- QQ扫一扫
-
- 我的头条
- 头条扫一扫
-
评论