# Privilege escalation not working

**URL:** <https://forum.ansible.com/t/privilege-escalation-not-working/27219>\
**Category:** Ansible Project\
**Created:** [April 8, 2018, 4:57pm UTC](https://forum.ansible.com/t/privilege-escalation-not-working/27219 "2018-04-08T16:57:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaushik\_Gosar](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@Kaushik\_Gosar](https://forum.ansible.com/u/Kaushik_Gosar)\
**Post date:** [April 8, 2018, 4:57pm UTC](https://forum.ansible.com/t/privilege-escalation-not-working/27219/1 "2018-04-08T16:57:38Z")

</div>

Hi,

I am trying to execute an Ad-Hoc command which requires sudo privileges on a remote machine.

Below is the command and the error it throws up

kaushik@Machine\_1:~$ ansible all -a “cat /etc/shadow” -u kaushik --ask-become-pass  
SUDO password:  
192.168.101.12 | FAILED | rc=1 \>\>  
cat: /etc/shadow: Permission denied

kaushik@Machine\_1~$

If I ssh to the machine and execute the same command “cat /etc/shadow” , it works without any errors.

Any idea how to fix this?

Thanks in advance,

Kaushik

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [April 8, 2018, 6:16pm UTC](https://forum.ansible.com/t/privilege-escalation-not-working/27219/2 "2018-04-08T18:16:37Z")

</div>

Mobile right now, but looks like you need a become method and or become user.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 8, 2018, 7:38pm UTC](https://forum.ansible.com/t/privilege-escalation-not-working/27219/3 "2018-04-08T19:38:37Z")

</div>

--ask-become-pass doesn't imply become so you need add -b or --become to use become.

---

<div class="post-metadata">

**Author:** ![Kaushik\_Gosar](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@Kaushik\_Gosar](https://forum.ansible.com/u/Kaushik_Gosar)\
**Post date:** [April 9, 2018, 5:23am UTC](https://forum.ansible.com/t/privilege-escalation-not-working/27219/4 "2018-04-09T05:23:08Z")

</div>

Hi Kai,

After posting this question, I went through the Ansible documentation again. It’s working after using the -b and -K option as I have not configured passwordless sudo.

Thanks for the reply.
