LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   About sudo (https://www.linuxquestions.org/questions/linux-software-2/about-sudo-572074/)

ust 07-25-2007 01:06 AM

About sudo
 
I want to let a user (eg. userA)have the permission to su another user (eg. userB), I would like to ask if I release the sudo function to userA , userA except can su to userB , whether userA have full function as root ?

thx

ust 07-25-2007 02:09 AM

Quote:

Originally Posted by ust
I want to let a user (eg. userA)have the permission to su another user (eg. userB), I would like to ask if I release the sudo function to userA , userA except can su to userB , whether userA have full function as root ?

thx

I hve test that , if release sudo to a user , the user will have ALL function of root , if I just want a user ONLY have the permission to su another user ( on other root permission ) , what can i do ? thx

gloriant 07-25-2007 03:44 AM

if you examine the syntax of /etc/sudoers, you'll discover it allows limitation in (originating) hosts, users and commands. You can execute sudo not only so that the instructions are executed as root, but also so the instructions (commands) are executed as another user:
Code:

sudo [-u <username>] <command>
If you omit the -u option, commands are normally executed as root. Now if you put in /etc/sudoers (through visudo, but I guess you know that),
Code:

userA ALL=( userB ) /bin/ls, /bin/cat
This will allow userA to execute commands ls and cat as user userB. This through:
Code:

sudo -u userB /bin/cat ~userB/.ssh/id_dsa
but no other commands (safe ls and cat) are accepted, no other users either. userA can try (but will fail) to execute for instance sudo /bin/cat /var/log/messages, but the system will detect that userA cannot execute /bin/cat as user root.

If however you want that user to be able to su as that user, you could inscribe
Code:

userA ALL=( userB ) /bin/bash
. This enables userA to do one of both:
Code:

sudo -u userB -s
and
Code:

sudo -u userB /bin/bash -i
Even more info, you'll find in man sudo, man visudo and man sudoers, and examples, you'll find amongst others in http://www.linuxhomenetworking.com/w...2Fsudoers_File


All times are GMT -5. The time now is 07:34 PM.