Wednesday, June 13, 2012

Allow sudo to run any command as another non-privileged user

Ever need to have the ability to run sudo to trigger a command as another non-root user?

Give this a try sometime:
icinga ALL = (ubuntu) NOPASSWD:ALL

This allows the user icinga to run anything it wants as ubuntu without asking for a password. You trigger this by having icinga trigger the command like:
sudo -u ubuntu -i /home/ubuntu/bin/awesome_script.sh 

Image systems via rsync


In case you ever need to, say, back up a system to a massive fileserver you have lying around, try this:

Client:
gzip /dev/sda | nc myserver 33333
Server:
nc -l 33333 > foo-laptop-2012-06-image.gz