sudoers to execute commands as another user
I'd like to allow one of my users to execute commands as another user on my Ubuntu Lucid server.
I'm struggling with finding the syntax for the sudoers file to do this. Say I'm connecting to the box with a user called 'ludo', and I want ludo to be able to execute commands as the 'django' user. eg:
sudo -u django
I'd like to be able to execute /any/ commands as the django user, and without prompting for a passsword. All the examples I find are for a restricted subset. I did attempt something but got a syntax error upon exiting visudo so I bottled it.
Thanks :)
Solution 1:
You can put the user to run as in parentheses before the command list:
ludo ALL = (django) NOPASSWD: ALL
Solution 2:
For a finer grained control you could consider defining the specific command that ludo
will be running as django
.
ludo ALL=(django) NOPASSWD: /usr/bin/python