# user  is not allowed to execute '/bin/sh -c

**URL:** <https://forum.ansible.com/t/user-is-not-allowed-to-execute-bin-sh-c/19264>\
**Category:** Ansible Project\
**Created:** [September 15, 2015, 4:43am UTC](https://forum.ansible.com/t/user-is-not-allowed-to-execute-bin-sh-c/19264 "2015-09-15T04:43:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivas\_Kotaru](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@Srinivas\_Kotaru](https://forum.ansible.com/u/Srinivas_Kotaru)\
**Post date:** [September 15, 2015, 4:43am UTC](https://forum.ansible.com/t/user-is-not-allowed-to-execute-bin-sh-c/19264/1 "2015-09-15T04:43:05Z")

</div>

Hi

Am having a issue to use ansible in our environment. We use sudo to run any commands. We don’t use root to login. In fact even hosting team don’t use root account. Every command ( privileged) has to be run as sudo.

Am getting below error while running command with sudo permission

# ansible -m command -a ‘ls -l /root’ all -i ~/remote/idev-lae-alln.txt -s -K

SUDO password:

\*\*\*\*\*\*\*\* | FAILED \>\> {

“failed”: true,

“msg”: “\r\nSorry, user skotaru is not allowed to execute ‘/bin/sh -c echo BECOME-SUCCESS-slpnqacunsytplnjohmwkjegpwaqrrej; LANG=en\_US.UTF-8 LC\_CTYPE=en\_US.UTF-8 /usr/bin/python /users/skotaru/.ansible/tmp/ansible-tmp-1442043902.14-245070656172900/command; rm -rf /users/skotaru/.ansible/tmp/ansible-tmp-1442043902.14-245070656172900/ \>/dev/null 2\>&1’ as root on \*\*\*\*\*\*\*\*\*\*.\r\nShared connection to \*\*\*\*\*\*\*\*\*\*\*\*\* closed.\r\n”,

“parsed”: false

}

It seems our hosting team disabled using /bin/sh or /bin/bash with sudo . I am able to issue sudo after logging to server and run any privileged commands.

Do you have any solution ? Without this feature, i won’t be able to take advantage of ansible except running few unprivileged commands.

Am able to issue unprivileged commands and running fine with ansible.

Srinivas Kotaru

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 15, 2015, 2:25pm UTC](https://forum.ansible.com/t/user-is-not-allowed-to-execute-bin-sh-c/19264/2 "2015-09-15T14:25:31Z")

</div>

no, sadly ansible needs to be able to run a shell as the commands it  
runs are temporary scripts it copies over and not specific commands  
that can be listed.

---

<div class="post-metadata">

**Author:** ![Srinivas\_Kotaru](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@Srinivas\_Kotaru](https://forum.ansible.com/u/Srinivas_Kotaru)\
**Post date:** [September 18, 2015, 6:58am UTC](https://forum.ansible.com/t/user-is-not-allowed-to-execute-bin-sh-c/19264/3 "2015-09-18T06:58:04Z")

</div>

is anything we can do? by changing to paramiko etc? our hosting team not allowing sudo on shells. This is limiting our ability to execute sudo commands.

Srinivas Kotaru

---

<div class="post-metadata">

**Author:** ![Jeff1](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jeff1](https://forum.ansible.com/u/Jeff1)\
**Post date:** [November 10, 2015, 12:35pm UTC](https://forum.ansible.com/t/user-is-not-allowed-to-execute-bin-sh-c/19264/4 "2015-11-10T12:35:29Z")

</div>

Put the remote sudo inside your command and ignore the Ansible sudo - it does not work as most people expect.

ansible -m command -a ‘sudo ls -l /root’ all
