问题描述
我为 Amazon EC2
创建了一个自动缩放组,并且在使用 packer
创建 AMI 时添加了我的公钥,我可以运行 ansible-playbook 和 ssh 以主持人.
I have created an autoscaling group for Amazon EC2
and I have added my public key when I created the AMI with packer
, I can run ansible-playbook and ssh to the hosts.
但是当我这样运行剧本时出现问题ansible-playbook load.yml
我收到这条消息,我需要输入密码
But there is a problem when I run the playbook like thisansible-playbook load.yml
I am getting this message that I need to write my password
输入密钥/Users/XXX/.ssh/id_rsa"的密码:
输入密码对于密钥/Users/XXX/.ssh/id_rsa":
输入密钥的密码'/Users/XXX/.ssh/id_rsa':
问题是它不接受我的密码(我确定我输入的密码正确).
The problem is it doesn't accept my password (I am sure I am typing my password correctly).
我发现我可以使用 ask-pass
标志发送我的密码,所以我将命令更改为 ansible-playbook load.yml --ask-pass
和我取得了一些进展,但对于其他一些任务,它再次要求输入密码,但它不接受我的密码
I found that I can send my password with ask-pass
flag, so I have changed my command to ansible-playbook load.yml --ask-pass
and I got some progress but again for some other task it asks for the password again and it didn't accept my password
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] *************************************************************************************************************
TASK [ec2_instance_facts] ****************************************************************************************************
ok: [localhost]
TASK [add_host] **************************************************************************************************************
changed: [localhost] => (item=xx.xxx.xx.xxx)
changed: [localhost] => (item=yy.yyy.yyy.yyy)
PLAY [instances] *************************************************************************************************************
TASK [Copy gatling.conf] *****************************************************************************************************
ok: [xx.xxx.xx.xxx]
ok: [yy.yyy.yyy.yyy]
Enter passphrase for key '/Users/ccc/.ssh/id_rsa': Enter passphrase for key '/Users/ccc/.ssh/id_rsa':
Enter passphrase for key '/Users/ccc/.ssh/id_rsa':
Enter passphrase for key '/Users/ccc/.ssh/id_rsa':
Enter passphrase for key '/Users/ccc/.ssh/id_rsa':
如果我不使用 ask-pass
标志,即使任务 [Copy gatling.conf]
也没有完成并抱怨无法访问主机.通过添加标志,这部分通过了,但我的下一个任务再次要求通过.
If I don't use ask-pass
flag even the task [Copy gatling.conf]
doesn't complete and complaining about could not access the hosts. By adding the flag this part passes, but my next task again asks for pass.
我该如何解决这个问题?我在这里做错了什么?
How should I solve this issue? What am I doing wrong here?
推荐答案
我通过运行一次 ssh-add
解决了这个问题,就像没有密码保护一样使用它.
I solved it by running ssh-add
once and use it like if it's not password protected.
这篇关于如何使用密码保护的 ssh-private-key 运行 ansible-playbook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!