1

I followed this question in order to enable sudo command for my created user. So I added it into the wheels group and edited the /etc/sudoers file accordingly.

But what I don't get about this is when I type for instance sudo yum install, it requires password of that user, not the password of root. This seems really insecure because if the account gets compromised, you can access root's functions with that users password.

Shouldn't it work in the way that if you want root rights, than you need to know root's password?

  • This is the correct behavior. – Piccolo Jul 9 '14 at 14:56
5

That's how sudo works. You trust the user and the user's actions are logged.

If you want to enter the root password, then you want to use the su command as follows:-

su -c yum install <package>
Password:

Once the command above finishes, you're returned to your normal user's prompt.

  • su is an older command that does what you want, but sudo was written so we don't need to pass root password to all the users. You should be able to configure PAM to let you login using a different system (ssh passphrase for example), then you would need 2 passwords to become root, but still your own passwords. – ctrl-alt-delor Jul 9 '14 at 18:23
3

Well it is how it's done. You will grant the permission to users of group wheel to perform administration duties. In short you grant them root access.

And this is not distro specific - in all Linux distributions and even BSDs you will do the same.

If you're worried about compromising security you could remove the user from sudoers table and go with root.

#> su root
Enter password
root #> yum install ...

This way you use root password and only root user has admin privileges.
Yes it is possible to do exotic setups with your sudoers table, but it's not really the routine way.

For all you could learn about sudo visit here

  • su means switch user. So do su root to become root. su <your_username> will return your terminal prompt to <your_usrname>.
2

As the other answerers said, this is the default behavior.

If you really want to enter the root password instead of the user's password, you can add the line

Defaults rootpw

to your /etc/sudoers file (use the visudo command, do not edit the sudoers file by any other means).

The usual disclaimer:

The defaults chosen for sudo are the way they are for a reason. Changing them may easily do you more harm than good. Read the man pages.

You could do worse than get a copy of Michael W. Lucas's Sudo Mastery: User Access Control for Real People if you really want to grok sudo.

1

You can increase security by restricting the commands that a "sudo user" can run. This is highly recommended. This is the syntax on a Debian box I have, might be slightly different depending on the system.

Cmnd_Alias      USER_COMMAND = /bin/user_admin
someuser  ALL = PASSWD : USER_COMMAND

This way someuser can only run the command /bin/user_admin as root. You can add multiple commands separated by a comma like this:

Cmnd_Alias      USER_COMMAND = /bin/user_admin,/sbin/fdisk,/some/other/cmd

For your specific system syntax you can check out man sudoers.

If you give away the root password, why would you need sudo?

The point of sudo is to give users super user privileges, without giving them full root access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.