ansible 提示安裝sshpass

以前用ansible一直用的root身份、機器之間又早早的作好了ssh信任、因此一直也沒有出現什麼問題。今天想一想本身不能這麼浪了,仍是用回普通用戶吧;ssh

然而立刻就遇到了第一個問題,ansible提示安裝sshpass這個軟件包。測試

1、ansible提示安裝sshpass這個軟件包:spa

ansible workstudio -m ping
workstudio | FAILED! => {
    "failed": true,
    "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}

 

2、安裝sshpass :code

yum -y install sshpass
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: mirrors.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package sshpass.x86_64 0:1.06-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================
 Package                       Arch                         Version                          Repository                  Size
==============================================================================================================================
Installing:
 sshpass                       x86_64                       1.06-1.el7                       epel                        21 k

Transaction Summary
==============================================================================================================================
Install  1 Package

Total download size: 21 k
Installed size: 38 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/sshpass-1.06-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for sshpass-1.06-1.el7.x86_64.rpm is not installed
sshpass-1.06-1.el7.x86_64.rpm                                                                          |  21 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-9.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : sshpass-1.06-1.el7.x86_64                                                                                  1/1 
  Verifying  : sshpass-1.06-1.el7.x86_64                                                                                  1/1 

Installed:
  sshpass.x86_64 0:1.06-1.el7                                                                                                 

Complete!

 

3、注意sshpass這個包並不在系統光盤裏面,它是epel這人源中包涵的包blog

 

4、測試ansible是否可用了:ci

ansible workstudio -m ping
workstudio | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

 

5、什麼狀況會出現要求安裝sshpass:it

  若是在/etc/ansible/host 中配置的ssh登陸用戶使用的是密鑰的認證是不會出現這個問題的;也就是說io

  一、在運行ansible的主機上要與被控機創建ssh信任。ast

  二、在/etc/ansible/host文件中不要指ansible_ssh_pass這個變量,否則它就強制走密碼認證了,而不是密鑰。 class

 

----

相關文章
相關標籤/搜索