sudo command ask for a password even with the NOPASSWD condition

Standard

After a hardware problems with my hard disk, I decided to get rid of it and install arch o a new hard disk.

After setting up the graphical environment, one of the configuration I like for my personal computer, discouraged for servers, is to configure sudo for not to ask for my password in each bash session. As said, it’s not recommended to do this, but I’m too lazy to put my password again and again.

So, as you may already know, in order to say to sudo command do not ask for the user password, it execute as root the visudo command and let the user or the group to execute all commands without password.

If you want to your user (malevolent in my case) to execute all sudo command withou password, you must type this when visudo opens.

malevolent ALL=(ALL) NOPASSWD: ALL

Perhaps your user belongs to the wheel group, so you can give to the entire group those rights, but this is even less recommended.

%wheel ALL=(ALL) NOPASSWD: ALL

In both cases, today I faced a new problem. The system continued asking me for my password. Ignoring those entries.

Looking the visudo documentation, it says:

When multiple entries match for a user, they are applied in order.  Where there are multiple matches, the last match is used (which is not  necessarily the most specific match).

So I look my entries with the following command

$ sudo -l
User malevolent may run the following commands on malevolo:
(ALL) NOPASSWD: ALL
(ALL) ALL

An it seems that the nopasswd entry is ignored by the all entry. So including my user just below the root user inside sudoers, did not make the job. After placing the line

malevolent ALL=(ALL) NOPASSWD: ALL

At the very end of the file, executing the last command now it returns:

$ sudo -l
User malevolent may run the following commands on malevolo:
(ALL) ALL
(ALL) NOPASSWD: ALL

And now my system does not ask for my password.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s