I'm trying to test ansible with a "pip" installation of ansible in a virtualenv of python managed by virtualenvwrapper. However, I am having problems to use the ssh-agent and the SSH keys:

(ansible)$ ansible all -m ping
Enter passphrase for key '/home/jtbpizac/.ssh/id_rsa':
Enter passphrase for key '/home/jtbpizac/.ssh/id_rsa':
Enter passphrase for key '/home/jtbpizac/.ssh/id_rsa':
Enter passphrase for key '/home/jtbpizac/.ssh/id_rsa':
Enter passphrase for key '/home/jtbpizac/.ssh/id_rsa':

However, I can use the ssh-agent from this shell to connect remotely through ssh without problems:

(ansible)$ ssh root@X.X.X.X

And the ssh-agent seems to be available from the shell I launch ansible:

(ansible)$ ssh-add -l
2048 SHA256:.. (RSA)
1024 SHA256:.. (DSA)
2048 SHA256:.. (RSA)
(ansible)$ ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-yE20HcbylzCJ/agent.14461; export SSH_AUTH_SOCK;
echo Agent pid 14462;

Any idea? I am using Ubuntu 15.10. Thanks!

  • First run ansible all -m ping -vvv for more detailed info. – techraf Mar 2 '16 at 14:45
  • In the first example you are logging in as your user (-ping), in the second as root. It is not exactly the same login. – Rui F Ribeiro Mar 2 '16 at 15:02
  • 2
    I finally got the problem. I needed to specify the user to connect through ssh. Sorry for the mesh: ansible all -u root -m ping. @RuiFRibeiro was right! – chrpinedo Mar 3 '16 at 11:17
  • exactly. I do advise also to not connect as root and use sudo. I use ansible that way and it works pretty well. ssh disables root by default for very good reasons – Rui F Ribeiro Mar 3 '16 at 13:57

In the file ~/.ansible.cfg, locallly, add:


Ansible by default uses paramiko( a Python ssh tool ). The above will tell ansible to use your local ssh (openssh usually).

  • paramiko is not used by default in current versions of Ansible (since Ansible 1.3) - see this doc section. – RichVel Nov 13 '16 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.