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

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.

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

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.