Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I don't have much experience with this type of task and realize I need to get more familiar with the sudoers file. I want a user to be able to connect via ssh and run a script that performs a bunch of libvirt and lvm commands like virsh list and lvcreate. The script is interactive, and was created to stop this user from messing stuff up, however I seem to be having trouble allowing the user to run this script as root without allowing access to the commands directly, circumventing the script. What is the best practice here if my only need is for the user to connect and run this script, performing actions as root, but not allowing any other access from said user?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Add the following to the sudoersfile, assuming the user is named bob:

bob ALL=(ALL) /path/to/script

That said, I would start by educating the user on proper use of commands/system he gets access to. Sudo should not be used as a replacement for trust.

share|improve this answer
    
It's worth adding to that, because the location of where you add that to the sudoers file is important. It's also important that edits are performed using visudo –  Bryan Apr 15 '13 at 18:38
    
I don't know why, but I tried this earlier and somehow it wasn't working, but now it is. Does the user have to log out and then log back in for visudo changes to take effect? –  user160910 Apr 15 '13 at 20:03
    
No, these take effect immediately. –  Dennis Kaarsemaker Apr 15 '13 at 20:30

Your Answer

 
discard

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