Block a command from sudo user
I don't need an administrator to change my root password. I don't want any sudo user to execute this command:
sudo passwd $root
I have tried it in the sudoers file using the following command:
%sudo ALL=(ALL) ALL, !/usr/bin/passwd $root
How can I block it?
sudo root
add a comment |
I don't need an administrator to change my root password. I don't want any sudo user to execute this command:
sudo passwd $root
I have tried it in the sudoers file using the following command:
%sudo ALL=(ALL) ALL, !/usr/bin/passwd $root
How can I block it?
sudo root
Do you mean that you have more than one sudo-able user in your system? Or something else? Please, edit the question to provide any new information.
– edwin
Jul 21 '14 at 20:09
add a comment |
I don't need an administrator to change my root password. I don't want any sudo user to execute this command:
sudo passwd $root
I have tried it in the sudoers file using the following command:
%sudo ALL=(ALL) ALL, !/usr/bin/passwd $root
How can I block it?
sudo root
I don't need an administrator to change my root password. I don't want any sudo user to execute this command:
sudo passwd $root
I have tried it in the sudoers file using the following command:
%sudo ALL=(ALL) ALL, !/usr/bin/passwd $root
How can I block it?
sudo root
sudo root
edited Jul 21 '14 at 18:50
Parto
9,4561965105
9,4561965105
asked Jul 21 '14 at 15:36
Magesh ArumugamMagesh Arumugam
101115
101115
Do you mean that you have more than one sudo-able user in your system? Or something else? Please, edit the question to provide any new information.
– edwin
Jul 21 '14 at 20:09
add a comment |
Do you mean that you have more than one sudo-able user in your system? Or something else? Please, edit the question to provide any new information.
– edwin
Jul 21 '14 at 20:09
Do you mean that you have more than one sudo-able user in your system? Or something else? Please, edit the question to provide any new information.
– edwin
Jul 21 '14 at 20:09
Do you mean that you have more than one sudo-able user in your system? Or something else? Please, edit the question to provide any new information.
– edwin
Jul 21 '14 at 20:09
add a comment |
2 Answers
2
active
oldest
votes
According to sudoers manual:
It is generally not effective to "subtract" commands from ALL using the
’!’ operator. A user can trivially circumvent this by copying the
desired command to a different name and then executing that. For
example:
bill ALL = ALL, !SU, !SHELLS
Doesn’t really prevent bill from running the commands listed in SU or
SHELLS since he can simply copy those commands to a different name, or
use a shell escape from an editor or other program. Therefore, these
kind of restrictions should be considered advisory at best (and
reinforced by policy).
This is why your sudoers policy doesn't work.
If you would like to prevent user to gain root permission and change its password, try this procedure:
Assuming your sudoers contains this directive:
root ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL
Assuming your user name is
foo
, his groups arefoo
andsudo
.groups
command output is:
foo sudo
Remove user
foo
fromsudo
group:gpasswd -d foo sudo
after this, userfoo
can not run any command with sudo.
Edit sudoers file. Use this command:
sudo visudo -f /etc/sudoers.d/foo
Define user
foo
permission, for example:
foo ALL=/usr/bin, !/usr/bin/passwd, !/usr/bin/su
This means that user
foo
may run any commands in the directory/usr/bin/
exceptpasswd
andsu
command.
Note: If the userfoo
wants to change his password, can runpasswd
command withoutsudo
.
Another example of user
foo
permission:
foo ALL =/usr/bin, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
This means that user
foo
may run any commands in the directory/usr/bin/
and is allowed to change anyone’s password except for root on ALL machines.
You can define groups of command by define Cmnd_Aliases
and create "levels of permissions". You can found useful examples in EXAMPLE section of sudoers manual, and here is a useful link about how to use sudoers.
I had to dofoo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?
– clurect
Sep 26 '17 at 18:13
add a comment |
add command alias via visudo
:
Cmnd_Alias PASSWD=/usr/bin/passwd
Cmnd_Alias SU=/bin/su
add restrictions via visudo
:
%nopasswdgroup ALL = ALL, !PASSWD, !SU
add user to group called nopasswdgroup:
usermod -aG nopasswdgroup nopasswduser
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f500679%2fblock-a-command-from-sudo-user%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to sudoers manual:
It is generally not effective to "subtract" commands from ALL using the
’!’ operator. A user can trivially circumvent this by copying the
desired command to a different name and then executing that. For
example:
bill ALL = ALL, !SU, !SHELLS
Doesn’t really prevent bill from running the commands listed in SU or
SHELLS since he can simply copy those commands to a different name, or
use a shell escape from an editor or other program. Therefore, these
kind of restrictions should be considered advisory at best (and
reinforced by policy).
This is why your sudoers policy doesn't work.
If you would like to prevent user to gain root permission and change its password, try this procedure:
Assuming your sudoers contains this directive:
root ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL
Assuming your user name is
foo
, his groups arefoo
andsudo
.groups
command output is:
foo sudo
Remove user
foo
fromsudo
group:gpasswd -d foo sudo
after this, userfoo
can not run any command with sudo.
Edit sudoers file. Use this command:
sudo visudo -f /etc/sudoers.d/foo
Define user
foo
permission, for example:
foo ALL=/usr/bin, !/usr/bin/passwd, !/usr/bin/su
This means that user
foo
may run any commands in the directory/usr/bin/
exceptpasswd
andsu
command.
Note: If the userfoo
wants to change his password, can runpasswd
command withoutsudo
.
Another example of user
foo
permission:
foo ALL =/usr/bin, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
This means that user
foo
may run any commands in the directory/usr/bin/
and is allowed to change anyone’s password except for root on ALL machines.
You can define groups of command by define Cmnd_Aliases
and create "levels of permissions". You can found useful examples in EXAMPLE section of sudoers manual, and here is a useful link about how to use sudoers.
I had to dofoo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?
– clurect
Sep 26 '17 at 18:13
add a comment |
According to sudoers manual:
It is generally not effective to "subtract" commands from ALL using the
’!’ operator. A user can trivially circumvent this by copying the
desired command to a different name and then executing that. For
example:
bill ALL = ALL, !SU, !SHELLS
Doesn’t really prevent bill from running the commands listed in SU or
SHELLS since he can simply copy those commands to a different name, or
use a shell escape from an editor or other program. Therefore, these
kind of restrictions should be considered advisory at best (and
reinforced by policy).
This is why your sudoers policy doesn't work.
If you would like to prevent user to gain root permission and change its password, try this procedure:
Assuming your sudoers contains this directive:
root ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL
Assuming your user name is
foo
, his groups arefoo
andsudo
.groups
command output is:
foo sudo
Remove user
foo
fromsudo
group:gpasswd -d foo sudo
after this, userfoo
can not run any command with sudo.
Edit sudoers file. Use this command:
sudo visudo -f /etc/sudoers.d/foo
Define user
foo
permission, for example:
foo ALL=/usr/bin, !/usr/bin/passwd, !/usr/bin/su
This means that user
foo
may run any commands in the directory/usr/bin/
exceptpasswd
andsu
command.
Note: If the userfoo
wants to change his password, can runpasswd
command withoutsudo
.
Another example of user
foo
permission:
foo ALL =/usr/bin, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
This means that user
foo
may run any commands in the directory/usr/bin/
and is allowed to change anyone’s password except for root on ALL machines.
You can define groups of command by define Cmnd_Aliases
and create "levels of permissions". You can found useful examples in EXAMPLE section of sudoers manual, and here is a useful link about how to use sudoers.
I had to dofoo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?
– clurect
Sep 26 '17 at 18:13
add a comment |
According to sudoers manual:
It is generally not effective to "subtract" commands from ALL using the
’!’ operator. A user can trivially circumvent this by copying the
desired command to a different name and then executing that. For
example:
bill ALL = ALL, !SU, !SHELLS
Doesn’t really prevent bill from running the commands listed in SU or
SHELLS since he can simply copy those commands to a different name, or
use a shell escape from an editor or other program. Therefore, these
kind of restrictions should be considered advisory at best (and
reinforced by policy).
This is why your sudoers policy doesn't work.
If you would like to prevent user to gain root permission and change its password, try this procedure:
Assuming your sudoers contains this directive:
root ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL
Assuming your user name is
foo
, his groups arefoo
andsudo
.groups
command output is:
foo sudo
Remove user
foo
fromsudo
group:gpasswd -d foo sudo
after this, userfoo
can not run any command with sudo.
Edit sudoers file. Use this command:
sudo visudo -f /etc/sudoers.d/foo
Define user
foo
permission, for example:
foo ALL=/usr/bin, !/usr/bin/passwd, !/usr/bin/su
This means that user
foo
may run any commands in the directory/usr/bin/
exceptpasswd
andsu
command.
Note: If the userfoo
wants to change his password, can runpasswd
command withoutsudo
.
Another example of user
foo
permission:
foo ALL =/usr/bin, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
This means that user
foo
may run any commands in the directory/usr/bin/
and is allowed to change anyone’s password except for root on ALL machines.
You can define groups of command by define Cmnd_Aliases
and create "levels of permissions". You can found useful examples in EXAMPLE section of sudoers manual, and here is a useful link about how to use sudoers.
According to sudoers manual:
It is generally not effective to "subtract" commands from ALL using the
’!’ operator. A user can trivially circumvent this by copying the
desired command to a different name and then executing that. For
example:
bill ALL = ALL, !SU, !SHELLS
Doesn’t really prevent bill from running the commands listed in SU or
SHELLS since he can simply copy those commands to a different name, or
use a shell escape from an editor or other program. Therefore, these
kind of restrictions should be considered advisory at best (and
reinforced by policy).
This is why your sudoers policy doesn't work.
If you would like to prevent user to gain root permission and change its password, try this procedure:
Assuming your sudoers contains this directive:
root ALL=(ALL:ALL) ALL
%sudo ALL=(ALL:ALL) ALL
Assuming your user name is
foo
, his groups arefoo
andsudo
.groups
command output is:
foo sudo
Remove user
foo
fromsudo
group:gpasswd -d foo sudo
after this, userfoo
can not run any command with sudo.
Edit sudoers file. Use this command:
sudo visudo -f /etc/sudoers.d/foo
Define user
foo
permission, for example:
foo ALL=/usr/bin, !/usr/bin/passwd, !/usr/bin/su
This means that user
foo
may run any commands in the directory/usr/bin/
exceptpasswd
andsu
command.
Note: If the userfoo
wants to change his password, can runpasswd
command withoutsudo
.
Another example of user
foo
permission:
foo ALL =/usr/bin, /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd root
This means that user
foo
may run any commands in the directory/usr/bin/
and is allowed to change anyone’s password except for root on ALL machines.
You can define groups of command by define Cmnd_Aliases
and create "levels of permissions". You can found useful examples in EXAMPLE section of sudoers manual, and here is a useful link about how to use sudoers.
edited Feb 14 '17 at 14:01
muru
1
1
answered Jul 21 '14 at 21:04
LetyLety
4,98521730
4,98521730
I had to dofoo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?
– clurect
Sep 26 '17 at 18:13
add a comment |
I had to dofoo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?
– clurect
Sep 26 '17 at 18:13
I had to do
foo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?– clurect
Sep 26 '17 at 18:13
I had to do
foo ALL=/usr/bin/*, !/usr/bin/passwd
any idea why that's the case?– clurect
Sep 26 '17 at 18:13
add a comment |
add command alias via visudo
:
Cmnd_Alias PASSWD=/usr/bin/passwd
Cmnd_Alias SU=/bin/su
add restrictions via visudo
:
%nopasswdgroup ALL = ALL, !PASSWD, !SU
add user to group called nopasswdgroup:
usermod -aG nopasswdgroup nopasswduser
add a comment |
add command alias via visudo
:
Cmnd_Alias PASSWD=/usr/bin/passwd
Cmnd_Alias SU=/bin/su
add restrictions via visudo
:
%nopasswdgroup ALL = ALL, !PASSWD, !SU
add user to group called nopasswdgroup:
usermod -aG nopasswdgroup nopasswduser
add a comment |
add command alias via visudo
:
Cmnd_Alias PASSWD=/usr/bin/passwd
Cmnd_Alias SU=/bin/su
add restrictions via visudo
:
%nopasswdgroup ALL = ALL, !PASSWD, !SU
add user to group called nopasswdgroup:
usermod -aG nopasswdgroup nopasswduser
add command alias via visudo
:
Cmnd_Alias PASSWD=/usr/bin/passwd
Cmnd_Alias SU=/bin/su
add restrictions via visudo
:
%nopasswdgroup ALL = ALL, !PASSWD, !SU
add user to group called nopasswdgroup:
usermod -aG nopasswdgroup nopasswduser
answered Feb 14 '17 at 14:02
shcherbakshcherbak
328211
328211
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f500679%2fblock-a-command-from-sudo-user%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you mean that you have more than one sudo-able user in your system? Or something else? Please, edit the question to provide any new information.
– edwin
Jul 21 '14 at 20:09