LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-23-2017, 12:40 AM   #1
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 106

Rep: Reputation: 17
Use of sudoers still asks for password


In the etc/sudoers file I have:

myusername ALL = NOPASSWD: /some_path/some_command

After logging in as 'myusername' I open a terminal and enter:

sudo /some_path/some_command

I am then asked for a password. Why would this ever happen ?
 
Old 04-23-2017, 03:10 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,420
Blog Entries: 10

Rep: Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237
Code:
myusername ALL = NOPASSWD: /some_path/some_command
please use code tags for code.
on my system it works, however there are no spaces before and after '=':
Code:
myusername ALL=NOPASSWD: /some_path/some_command
also, which command are you trying to execute?
are you seeing the standard sudo password dialog, or something else? please show us.
 
1 members found this post helpful.
Old 04-23-2017, 03:15 AM   #3
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918
Check /etc/sudoers for any other rules that affect myusername.

The NOPASSWD rule you want applied must appear last of the myusername-affecting rules in that file to take precedence.
 
1 members found this post helpful.
Old 04-23-2017, 03:16 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,655
Blog Entries: 11

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
I think the spaces are OK (at least mine works with spaces around '=').

The command must be _exactly_ as it appears in the sudoers file, including any trailing options, or you can use wildcards to allow options such as...
Code:
myusername ALL=NOPASSWD: /some_path/some_command *
If your command is aliased to something with trailing options, that may be a problem.

So, again, it would be helpful to know what the command is.

Last edited by astrogeek; 04-23-2017 at 03:23 AM. Reason: grammar
 
Old 04-23-2017, 03:44 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 17,420
Blog Entries: 10

Rep: Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237Reputation: 5237
Quote:
Originally Posted by hydrurga View Post
Check /etc/sudoers for any other rules that affect myusername.

The NOPASSWD rule you want applied must appear last of the myusername-affecting rules in that file to take precedence.
yes, it is the very last line in my sudoers.
 
Old 04-23-2017, 09:30 AM   #6
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 106

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by hydrurga View Post
Check /etc/sudoers for any other rules that affect myusername.

The NOPASSWD rule you want applied must appear last of the myusername-affecting rules in that file to take precedence.
That was the problem. A group to which I was automatically assigned when I installed the Linux distribution had a rule after my specific rule which referred to the command which I was trying to use, and expected a password.

Thanks ! I have learned something valuable which I did not know before.
 
Old 04-23-2017, 11:27 AM   #7
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918Reputation: 2918
Quote:
Originally Posted by eldiener View Post
That was the problem. A group to which I was automatically assigned when I installed the Linux distribution had a rule after my specific rule which referred to the command which I was trying to use, and expected a password.

Thanks ! I have learned something valuable which I did not know before.
My pleasure, eldiener.

If you want, you can mark the thread as "Solved" (see Thread Tools at the top of the thread).
 
Old 04-23-2017, 02:15 PM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by eldiener View Post
That was the problem. A group to which I was automatically assigned when I installed the Linux distribution had a rule after my specific rule which referred to the command which I was trying to use, and expected a password.

Thanks ! I have learned something valuable which I did not know before.
You can even set the sudo command itself no password to just rid yourself of it - if you feel the need to -- I know other have their options on this.
Code:
## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
or sudo - group how ever your system is setup to use sudo. Just change wheel to sudo.
 
  


Reply

Tags
password, sudo, sudoers


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PDF file asks for password but its not password protected? M$ISBS Linux - General 3 01-19-2015 07:47 PM
[SOLVED] RIPLinuX asks for a password... I don't know what password Vocay2 Linux - Software 2 10-12-2013 07:13 AM
[SOLVED] SSH: Asks for password: Permission denied (keyboard-interactive,password). tulicloure Linux - Newbie 7 02-14-2012 09:48 AM
is possible that sudo always asks the password? Lantius Linux - Software 5 05-09-2007 04:31 PM
Samba asks password element Linux - Networking 1 09-11-2003 04:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:10 PM.

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