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?


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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy