How to enter private key password with ansible

10,188

Try using ssh as the transport. Generally, Ansible uses paramiko which is not as friendly for interactive sessions:

ansible all -c ssh -m ping

If that doesn't work, I didn't see anything on running Ansible with an ssh key pass phrase on the documentation or in the code, so you might have to remove it with something like this:

openssl rsa -in private_key_with_pass_phrase -out private_key_without_pass_phrase
Share:
10,188
user3147180
Author by

user3147180

Updated on June 11, 2022

Comments

  • user3147180
    user3147180 almost 2 years

    I have the vagrant virtual machine running.

    I can ssh into it using ssh [email protected] then it ask me the pass phrase for the private key , which I can enter and then it logs me in.

    but if I use:

    ansible all -m ping

    then I get this:

    192.168.0.28 | FAILED => FAILED: ssh [email protected]:22 : Private key file is encrypted
    To connect as a different user, use -u <username>.
    

    How can I enter pass phrase in ansible?

    I tried ansible -k but it says authentication failed.

  • user3147180
    user3147180 about 10 years
    i removed the password, but it says authentication failed. how can i mention in ansible that i want to connect via username vagrant and not the username of host where i am executing ansible
  • Rico
    Rico about 10 years
    you can run ansible all -c ssh -m ping -u vagrant
  • L0j1k
    L0j1k over 9 years
    It's also possible to specify the user you want to login as inside the /etc/ansible/hosts file with ansible_ssh_user=ansible next to the hostname, or in /etc/ansible/ansible.cfg with remote_user=ansible. Of course, substituting your desired username instead of ansible as I have typed here.