# Connect to remote servers

**URL:** <https://forum.ansible.com/t/connect-to-remote-servers/15745>\
**Category:** Ansible Project\
**Created:** [July 23, 2014, 4:31pm UTC](https://forum.ansible.com/t/connect-to-remote-servers/15745 "2014-07-23T16:31:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narcis\_Pillao\_Figuer](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@Narcis\_Pillao\_Figuer](https://forum.ansible.com/u/Narcis_Pillao_Figuer)\
**Post date:** [July 23, 2014, 4:31pm UTC](https://forum.ansible.com/t/connect-to-remote-servers/15745/1 "2014-07-23T16:31:05Z")

</div>

Hi all,

I need to configure an instance which needs to connect to a remote server via ssh, I’ve been doing some tests and troubleshooting but I’m doing something wrong I guess, since when I’m tryin to connect to that ssh server, the connection gets stuck

A (ansible) → B (new server) -ssh\> C (remote server)

On ansible I see my key has been forwarded:

`$ ssh-add -l 2048 XXX Users/sisu/.ssh/id_rsa(RSA)`

allowing forwarding on ansible:

`$ grep args ansible.cfg ssh_args = "-o ForwardAgent=yes"`

Task:

---

<div class="post-metadata">

**Author:** ![Narcis\_Pillao\_Figuer](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@Narcis\_Pillao\_Figuer](https://forum.ansible.com/u/Narcis_Pillao_Figuer)\
**Post date:** [July 24, 2014, 2:09pm UTC](https://forum.ansible.com/t/connect-to-remote-servers/15745/2 "2014-07-24T14:09:10Z")

</div>

I found my problem.

As I was running ansible with sudo (-s) parameter, my ssh-agent socket was forwarded for the regular user only. Then I need to add “sudo: yes” to all the tasks I need sudo and be sure the task where I run ssh to remote tasks has no sudo.

This link helped me to find the problem: [https://github.com/ansible/ansible/issues/7235](https://github.com/ansible/ansible/issues/7235)

Thanks
