# ssh-agent module does error connecting to agent

**URL:** <https://forum.ansible.com/t/ssh-agent-module-does-error-connecting-to-agent/37783>\
**Category:** Ansible Developer\
**Created:** [March 20, 2023, 4:55am UTC](https://forum.ansible.com/t/ssh-agent-module-does-error-connecting-to-agent/37783 "2023-03-20T04:55:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frans\_van\_Berckel](https://avatars.discourse-cdn.com/v4/letter/f/8dc957/32.png) [@Frans\_van\_Berckel](https://forum.ansible.com/u/Frans_van_Berckel)\
**Post date:** [March 20, 2023, 4:55am UTC](https://forum.ansible.com/t/ssh-agent-module-does-error-connecting-to-agent/37783/1 "2023-03-20T04:55:02Z")

</div>

I found ssh\_agent.py by Google and tweaked a bit, but running does …

$ ansible -vvvvv -m ssh\_agent -a ‘ssh\_key\_file=/home/ansible/ssh/rsa\_id ssh\_env\_file=/home/ansible/.ssh-agent-env ssh\_passphrase=’ localhost

localhost | FAILED! =\> {

“changed”: false,  
“invocation”: {  
“module\_args”: {  
“ssh\_env\_file”: “/home/ansible/.ssh-agent-env”,  
“ssh\_key\_file”: “/home/ansible/ssh/rsa\_id”,  
“ssh\_passphrase”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”  
}  
},  
“msg”: “Error adding key and passphrase to agent: Error connecting to agent: No such file or directory\n”  
}

To me it looks like the ssh-add can’t connect ssh-agent in memory? Or ssh-add doesn’t use / can’t read ssh\_env\_file?

~$ ps -A | grep ssh-agent  
35583 ? 00:00:00 ssh-agent

~$ ls .ssh-agent-env  
.ssh-agent-env

$ cat .ssh-agent-env  
[default]  
ssh\_auth\_sock = /tmp/ssh-FwY7QOdRrW6h/agent.35582; export SSH\_AUTH\_SOCK;  
ssh\_agent\_pid = 35583; export SSH\_AGENT\_PID;

Any idea what goes wrong?

> **(attachments)**
>
> [ssh\_agent.txt](https://forum.ansible.com/uploads/short-url/grqjm2IzcQ3S59freLz1S4HOAtL.txt) (3.22 KB)
