# Using a jump box, is it possible to sudo su - to root before connecting to targets?

**URL:** <https://forum.ansible.com/t/using-a-jump-box-is-it-possible-to-sudo-su-to-root-before-connecting-to-targets/19277>\
**Category:** Ansible Project\
**Created:** [September 16, 2015, 7:34pm UTC](https://forum.ansible.com/t/using-a-jump-box-is-it-possible-to-sudo-su-to-root-before-connecting-to-targets/19277 "2015-09-16T19:34:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agent\_Gh](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Agent\_Gh](https://forum.ansible.com/u/Agent_Gh)\
**Post date:** [September 16, 2015, 7:34pm UTC](https://forum.ansible.com/t/using-a-jump-box-is-it-possible-to-sudo-su-to-root-before-connecting-to-targets/19277/1 "2015-09-16T19:34:19Z")

</div>

From our jump box, we sudo su - to root and then ssh into the other hosts as root. (I understand the security risks, but I don’t have control over this setup)

I’m wondering if I can setup ansible to that it connects to the jump box as my user, then does a sudo su -, so that when it sshes over to the targets, its actually connecting to them as root.

I know it’s possible to use proxycommand to make use of a jump box, but the sudo su -, I haven’t figured out.

The only variable I can control here is the box I’m originating from. Details that I don’t have control over:

- I can’t install ansible on the jump box.

- My user isn’t on the target hosts, only root.

- Root password is not known, we use private keys, which are only on the jump box.

- I cannot copy those keys to my box.

- I can’t ssh to the jump box as root.

---

<div class="post-metadata">

**Author:** ![Chris\_Grigor](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@Chris\_Grigor](https://forum.ansible.com/u/Chris_Grigor)\
**Post date:** [September 17, 2015, 10:55am UTC](https://forum.ansible.com/t/using-a-jump-box-is-it-possible-to-sudo-su-to-root-before-connecting-to-targets/19277/2 "2015-09-17T10:55:19Z")

</div>

Have you looked at  
[http://alexbilbie.com/2014/07/using-ansible-with-a-bastion-host/](http://alexbilbie.com/2014/07/using-ansible-with-a-bastion-host/)

---

<div class="post-metadata">

**Author:** ![Agent\_Gh](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Agent\_Gh](https://forum.ansible.com/u/Agent_Gh)\
**Post date:** [September 17, 2015, 1:12pm UTC](https://forum.ansible.com/t/using-a-jump-box-is-it-possible-to-sudo-su-to-root-before-connecting-to-targets/19277/3 "2015-09-17T13:12:30Z")

</div>

I have actually. In his example, he’s just connecting through a jump box, he isn’t connecting and then becoming root before connecting to the targets.
