Small Mosaic


Categories:

/books
/career
/codinghorrors
/events
/geekstuff
/justdont
/languages
/languages/bash
/linkshot
/magazines
/meta
/misctech
/movies
/nottech
/operatingsystems
/operatingsystems/linux
/operatingsystems/linux/debian
/operatingsystems/solaris
/perl
/presentations
/programming
/python
/ruby
/security
/security/apache
/security/tools
/serversmells
/services
/services/dns
/sites
/specifications
/sysadmin
/testing
/tools
/tools/commandline
/tools/firefox
/tools/gui
/tools/network
/tools/online
/tools/online/greasemonkey
/tools/puppet
/unixdaemon

Archives:

July 20111
June 20112
May 20113
April 20112
March 20117
January 20111
December 20103
November 20103
August 20101
July 20101
June 20104
May 20102
April 20101
March 20108
February 20101
January 20102
Full Archives

Fri, 29 Jul 2005

Using sudo Without A Password
If you add a NOPASSWD directive in your sudoers file then you can, as you'd expect from its name, use those commands without a password. This is a pretty useful trick that allows you to set up sudo entries that allow commands to be run with different privileges from cron without requiring the setuid flag. However twice this week I've seen a similar question asked on mailing lists and I thought I'd stick this entry up, hope google indexes it and saves me from ever seeing it again. Yeah right.

When you use sudo and authenticate it sets a short timeout period in which if you use sudo again it won't ask for your password. This is typically a useful feature (for interactive use anyway) but a couple of people seem to follow a series of events that go something like this: sudo visudo (add the NOPASSWD line). sudo "command I want in cron." "Oh look, it worked. Now let me add a cronjob." The next day they (hopefully) notice it didn't work and then ask on a mailing list. Which I'm on.

Now it seems obvious but people don't seem to realise that the trial run is pointless, the timestamp is still valid from when they ran sudo visudo and so sudo WILL NOT PROMPT FOR THE PASSWORD. In order to run a real test you need to use sudo -k to invalidate the timestamp and then rerun the command.

As a closing note adding a sudo -k to your .logout/.bash_logout file can also be a smart thing to do on some systems.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2005/07/29 13:33 | /tools/commandline | Permanent link to this entry | This entry and same date


books career codinghorrors events geekstuff justdont magazines meta misctech movies nottech operatingsystems/linux operatingsystems/linux/debian operatingsystems/solaris perl programming python ruby security security/apache security/tools serversmells services/dns sites sysadmin testing tools tools/commandline tools/firefox tools/gui tools/network tools/online tools/online/greasemonkey tools/puppet unixdaemon

Copyright © 2000-2010 Dean Wilson XML feed logo