# Doing su -c 'ssh {{ ssh\_peer }}'

**URL:** <https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213>\
**Category:** Ansible Project\
**Created:** [October 12, 2022, 5:31pm UTC](https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213 "2022-10-12T17:31:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [October 12, 2022, 5:31pm UTC](https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213/1 "2022-10-12T17:31:11Z")

</div>

Hi all,

This stopped working after some upgrade of ansible:

- - -  
&nbsp;&nbsp;- name: Test new ssh connection  
&nbsp;&nbsp;&nbsp;&nbsp;command: "su {{ sk\_user }} -c 'ssh {{ ssh\_peer }} date‘“  
- - -

It just hungs in the shell.

How can this be done in 2.13.1?

Any help appreciated,  
Axel

---

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [October 12, 2022, 5:48pm UTC](https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213/2 "2022-10-12T17:48:49Z")

</div>

OS is FreeBSD.

A.

---

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [October 12, 2022, 6:19pm UTC](https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213/3 "2022-10-12T18:19:18Z")

</div>

If I install sudo, this seems to work:

* * *

shell: sudo -u {{ sk\_user }} ssh {{ ssh\_peer }} date

* * *

Axel

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [October 13, 2022, 7:51am UTC](https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213/4 "2022-10-13T07:51:40Z")

</div>

> If I install sudo, this seems to work:  
> - - -  
> shell: sudo -u {{ sk\_user }} ssh {{ ssh\_peer }} date  
> - - -

Ansible can do the privilege escalation to an arbitrary user as well:

command: ssh {{ ssh\_peer }} date

become\_user: "{{ sympa\_unix\_user }}"  
vars:  
ansible\_ssh\_pipelining: true

Regards

```
       Racke

```

---

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [October 13, 2022, 8:44am UTC](https://forum.ansible.com/t/doing-su-c-ssh-ssh-peer/37213/5 "2022-10-13T08:44:11Z")

</div>

Looks good. Will try it!

Thanks,  
Axel
