Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run this script (it is post-receive hook of git repository):

echo "Executing post-receive hook as user `id` using `which sudo`"
sudo -l
sudo -n bash /var/project/autotest/

It should run without asking for password, but I got following output:

Executing post-receive hook as user uid=1005(martinjonas) gid=1001(martinjonas)
groups=1001(martinjonas),1009(lifeweb),1017(project) using /usr/bin/sudo
Matching Defaults entries for martinjonas on this host:

User martinjonas may run the following commands on this host:
    (root) NOPASSWD: /var/project/autotest/
sudo: sorry, a password is required to run sudo

As you can see acording to outputo of sudo -l I am supposed to be able run /var/project/autotest/ without password, but sudo still asks for password.

This is my sudoers file (it is whole file no additional entries there):

# /etc/sudoers
# This file MUST be edited with the 'visudo' command as root.
# See the man page for details on how to write a sudoers file.

Defaults        env_reset

# Host alias specification
# User alias specification
# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#includedir /etc/sudoers.d

www-data        ALL=(root) NOPASSWD: /usr/bin/svn up
%project       ALL=(root) NOPASSWD: /var/project/autotest/

I try to search for answer but only possible problems I found are wrong sudo used or wrong order of entires in sudoers, which I both disproved.

We use Debian 6.0 2. on this server.

share|improve this question
up vote 7 down vote accepted

you have NOPASSWD entry for /var/project/autotest/, but your command running bash /var/project/autotest/ - it's different command and that's why it forbidden

remove bash and all should work fine.

share|improve this answer
OMG such stupid mistake! :-) Thanks! – Martin Mystik Jonáš Oct 14 '13 at 14:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.