Privilege escalation not working

13 views
Skip to first unread message

Kaushik Gosar

unread,
Apr 8, 2018, 12:57:38 PM4/8/18
to Ansible Project
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

Andrew Latham

unread,
Apr 8, 2018, 2:17:03 PM4/8/18
to ansible...@googlegroups.com
Mobile right now, but looks like you need a become method and or become user.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8dcfab26-a80f-461b-a4d5-64de8a108fc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kai Stian Olstad

unread,
Apr 8, 2018, 3:38:56 PM4/8/18
to ansible...@googlegroups.com
--ask-become-pass doesn't imply become so you need add -b or --become to use become.

--
Kai Stian Olstad

Kaushik Gosar

unread,
Apr 9, 2018, 1:23:08 AM4/9/18
to Ansible Project
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.

--
Kaushik
Reply all
Reply to author
Forward
0 new messages