我有这个在我的库存:
ansible_user=<user>
ansible_connection=ssh
ansible_ssh_private_key_file=<location of key>
,我可以使用该用户和密钥ssh登录。
然而,当我运行剧本时,我得到:
{"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"}
就其价值而言,
Host OS: VERSION="20.04.1 LTS (Focal Fossa)"
ansible 2.9.9
有什么建议我可以让Ansible使用ssh密钥吗?
更新这是我得到的-vvvvv
:
ansible-playbook 2.9.9
config file = /path/to/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/user/.local/lib/python3.8/site-packages/ansible
executable location = /home/user/.local/bin/ansible-playbook
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Using /path/to/ansible.cfg as config file
Reading vault password file: /path/to/ansible-vault.txt
setting up inventory plugins
host_list declined parsing /path/to/inventory/inventory.win.aws as it did not pass its verify_file() method
script declined parsing /path/to/inventory/inventory.win.aws as it did not pass its verify_file() method
auto declined parsing /path/to/inventory/inventory.win.aws as it did not pass its verify_file() method
yaml declined parsing /path/to/inventory/inventory.win.aws as it did not pass its verify_file() method
Parsed /path/to/inventory/inventory.win.aws inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /home/user/.local/lib/python3.8/site-packages/ansible/plugins/callback/default.py
PLAYBOOK: playbook.yml ******************************************************************************
Positional arguments: playbook.yml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
inventory: ('/path/to/inventory',)
vault_password_files: ('/path/to/ansible-vault.txt',)
forks: 5
1 plays in playbook.yml
PLAY [all] ******************************************************************************************
TASK [Gathering Facts] ******************************************************************************
task path: /path/to/playbook.yml:2
<ip.address> ESTABLISH SSH CONNECTION FOR USER: some_user
fatal: [ip.address]: FAILED! => {
"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}
PLAY RECAP ******************************************************************************************
ip.address : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
- 验证您是否真的复制了您的公钥!
ssh-copy-id some_user@ip.address
。 - 启动SSH代理:
eval $(ssh-agent)
- 添加键
ssh-add ~/.ssh/<privkeyfile>
- 试试普通的ssh
ssh some_user@ip.address
应该登录没有提示… - 尝试ping
ansible all -i inventory -m ping -vvvv