本文介绍了如何使用密码保护的ssh-private-key运行ansible-playbook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Amazon EC2上有一个自动扩展组,并且在使用packer创建AMI时添加了公钥,因此我可以在主机上运行ansible-playbook和ssh.

I have an autoscaling group on Amazon EC2 and I have added my public key when I create AMI with packer so 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 this ansible-playbook load.yml I am getting this message that I need to write my password

问题是它不接受我的密码(我确定我输入的密码正确).

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并获得了一些进展,但是对于其他一些任务,它再次要求输入密码并且不接受我的密码

Then 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 dont 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 is going well 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 11:15