LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-21-2011, 09:59 AM   #1
joaquin386
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Rep: Reputation: 0
Sudo: NOPASSWD when doing useradd ask me for password


When I put these in the /etc/sudoers

opv ALL = NOPASSWD: /usr/sbin/useradd, /usr/sbin/userdel, /usr/sbin/groupadd, /usr/sbin/groupdel, /usr/sbin/groupmod, /usr/sbin/usermod, /usr/bin/chsh, /usr/bin/passwd
, /usr/bin/last, /bin/awk, /bin/cat, /bin/chmod, /bin/cp, /bin/chown, /bin/cut, /bin/diff, /bin/echo, /bin/grep, /bin/ln, /bin/ls, /bin/mv, /bin/ps, /bin/rm, /bin/sed,
/bin/sort, /usr/bin/tail, /bin/touch, /bin/chgrp, /bin/mkdir

opv user has to input the root password (when doing the useradd command) even though I put NOPASSWD how is this possible? I don't want any password prompt.

BR

Jo

Last edited by joaquin386; 01-21-2011 at 10:23 AM.
 
Old 01-21-2011, 10:50 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Try removing the commas in the sudoers file.
 
Old 01-21-2011, 11:24 AM   #3
joaquin386
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Original Poster
Rep: Reputation: 0
SOLVED:
Had to comment these lines out:

# Defaults targetpw # ask for the password of the target user i.e. root

# ALL ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!


I had those lines enable.
 
Old 01-21-2011, 11:25 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
You need to post the contents of you sudoers file--not just the line you want. When/if you post it, put the contents inside [code] <contents> [/code] tags in your reply.

The reason you need to post it is because subsequent directives in sudoers can override previous ones.

As an example, look at mine:
Code:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults	env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

darkhelmet	ALL=NOPASSWD: /sbin/shutdown, /usr/bin/apt-get update, /usr/bin/apt-get upgrade
I do not need to enter a password for any of the three commands listed. HOWEVER, if I swapped the last two lines like so:
Code:
darkhelmet	ALL=NOPASSWD: /sbin/shutdown, /usr/bin/apt-get update, /usr/bin/apt-get upgrade

%admin ALL=(ALL) ALL
I WOULD have to enter a password. The reason is because darkhelmet is part of the admin group. The last assignment overrides the previous assignment to the specific account.

At least, that's been my experience working with sudo. Like I said, you'll need to post your sudoers file for us to be certain.

EDIT: Looks like we posted at about the same time. Glad you got it working.

Last edited by Dark_Helmet; 01-21-2011 at 11:27 AM.
 
Old 01-21-2011, 11:28 AM   #5
joaquin386
LQ Newbie
 
Registered: Mar 2010
Posts: 12

Original Poster
Rep: Reputation: 0
True I should post the whole file. Next time (it would even be time saving for everyone)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo -u aUser nopasswd PoleStar Linux - Newbie 1 08-04-2010 05:08 PM
sudo NOPASSWD issue lensem Linux - Software 5 11-25-2009 05:08 PM
useradd -p <encrypted password> jeewiz Linux - Newbie 1 01-19-2007 08:17 AM
useradd without shadow password twallstr Linux - Software 1 09-08-2005 02:14 PM
Password Problems With useradd Jude Lucien Debian 4 08-18-2005 10:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration