Run sudo to another user


 
Thread Tools Search this Thread
Operating Systems AIX Run sudo to another user
# 1  
Old 03-27-2010
Run sudo to another user

Run sudo to another user .

I have two users in my AIX system appadmin (Application admin ) and appuser (Application user)
Application Admin user has special permission to run every thing about this application.

I have one script called /usr/app.sh
Only appadmin has permission to run this script
by sudo I want to let appuser to be able to run this script

by root I have configured the system as the following

visudo
%appuser ALL=( appadmin) /usr/app.sh

As per the above configuration appuser should has permission to run sudo and it should to execute that script
When appuser login to the system and when he type sudo –l

User appuser may run the following commands on this host:
(appuser) /usr/app.sh

Everything is ok till now .. but when he try to execute that command by sudo he will got the below

$ sudo /usr/app.sh
Sorry, user appuser is not allowed to execute '/usr/app.sh' as root on Appserver.

why it saying as root I configured sudo to run that script by appadmin and why is not allowed to execute that sicript !


Pls advice in this …


.

Last edited by Mr.AIX; 03-27-2010 at 07:29 AM..
# 2  
Old 03-28-2010
From the sudoers FAQ at FAQ and Troubleshooting Tips

Quote:
Q) When I run sudo it says I am not allowed to run the command as root
but I don't want to run it as root, I want to run it as another user.
My sudoers file entry looks like:
bob ALL=(oracle) ALL
A) The default user sudo tries to run things as is always root, even if
the invoking user can only run commands as a single, specific user.
This may change in the future but at the present time you have to
work around this using the 'runas_default' option in sudoers.
For example:
Defaults:bob runas_default=oracle
would achieve the desired result ofr the preceding sudoers fragment.
# 3  
Old 03-28-2010
I have confiogured the below in /etc/sudoers

Defaults always_set_home, runas_default=appadmin to sudoers
%appuser ALL=(appadmin) ALL



but still is not working !
# 4  
Old 03-29-2010
UNless you want to post the entire sudoers file I'm not sure I can help you much more. Can you check to see if there are additional lines that feature the appadmin user or the groups to which it belongs further on in the sudoers file. Sometimes these can overwrite rather that add to the privileges.
# 5  
Old 03-29-2010
look up I configured in sudoer file and executing of script will be by appuser as appadmin

but the still it's trying to execute it as root and it saying not allowed !

sudo configuration is not for the root !

is the default is root and if is it yes how to can I change it to be allowed for appadmin

Last edited by Mr.AIX; 03-29-2010 at 02:20 PM..
# 6  
Old 03-29-2010
Quote:
Originally Posted by Mr.AIX
look up I configured in sudoer file and executing of script will be by appuser as appadmin but the still it's trying to execute it as root and it saying not allowed !
This is exactly what ross.mather is trying to tell you: it might well be that other parts of the /etc/sudoers file are contradicting the part you have posted. So please post a C-O-M-P-L-E-T-E /etc/sudoers file (btw.: wrapping code-tags around it would be a nice touch) and not just the part you think is interesting.

I suppose you have double-checked the file modes for "/usr/app.sh" to make sure appadmin has indeed execution rights, haven't you?

bakunin
# 7  
Old 03-29-2010
The mode of /usr/app.sh is 777 and when I did the below sudo configuration to be executable by root

visudo
%appuser ALL=( root) /usr/app.sh

sudo –l

User appuser may run the following commands on this host:
(root) /usr/app.sh


sudo /usr/app.sh
executing for the application ..
application started ..

it'll work and it'll be executed by root but by appadmin it's giving me that mentioned message !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to automatically run commands after SSH and SUDO not working?

I'm working on a script to SSH and SUDO as (sap user sidadm) then automatically run commands that the sidadm user can run such as R3trans -v, tp, etc.. I can SSH without password and SUDO.. but the commands don't run after I SSH and SUDO to the sidadm user...here is the commands that I've... (2 Replies)
Discussion started by: icemanj
2 Replies

2. Shell Programming and Scripting

Preserving variable in script run with sudo

In a nutshell, I want $USER to reflect my user ID in a script run with sudo. I'm working with OSX in case that makes a difference. If I 'sudo echo $USER', I get my user ID. But if I 'sudo myscript.sh' and myscript.sh has a line to echo $USER, I get 'root' I'm hoping there's a switch I can add... (1 Reply)
Discussion started by: jnojr
1 Replies

3. Shell Programming and Scripting

Chmod working in sudo run script but chown isn't

My git user has permission in sudoers to run a wrapper script to move files into my webroot. Everything is working fine except for the chown line. After the script has run, the files ar still root:root instead of apache:apache. Scratching my head...:confused: #!/bin/sh echo echo "****... (4 Replies)
Discussion started by: dheian
4 Replies

4. Shell Programming and Scripting

How to run sudo commands under a script?

Hi, I am new to scripting. I am trying to write a script to ssh one remote machine and run a sudo command. ssh <hostname> sudo -S <command> < ~/pass.txt I am stored my password in pass.txt. I am getting error sudo: no tty present and no askpass program specified Please suggest me how can... (1 Reply)
Discussion started by: venkia9
1 Replies

5. Shell Programming and Scripting

sudo: sorry, you must have a tty to run sudo

Hi, Have a need to run the below command as a "karuser" from a java class which will is running as "root" user. When we are trying to run the below command from java code getting the below error. Command: sudo -u karuser -s /bin/bash /bank/karunix/bin/build_cycles.sh Error: sudo: sorry,... (8 Replies)
Discussion started by: Satyak
8 Replies

6. AIX

track commands run as root after sudo

I'm looking for a way to track commands that are run as root after a user runs sudo su - root. I have a profile set up for root that will track the commands by userid but if we change the shell it only stores it in that shells history file. (2 Replies)
Discussion started by: toor13
2 Replies

7. Shell Programming and Scripting

sudo: sorry, you must have a tty to run sudo

Hi All, I running a unix command using sudo option inside shell script. Its working well. But in crontab the same command is not working and its throwing "sudo: sorry, you must have a tty to run sudo". I do not have root permission to add or change settings for my userid. I can not even ask... (9 Replies)
Discussion started by: Apple1221
9 Replies

8. Cybersecurity

Unable to run 'su' and 'sudo' after changing permissions on /etc

Hello, I'm running rhel6 64bit. Accidentally I ran % chmod -R 777 /etc and after that I have a problem to do 'su' or 'sudo'. When I did sudo it complained that /etc/sudoers has 777 while it should be 0440. I changed that and also restored right permission for: -rw-r--r-- 1 root root 1966 May 19... (2 Replies)
Discussion started by: susja
2 Replies

9. UNIX for Dummies Questions & Answers

sudo user

I am trying to run a command from different user on my server. However when i execute the command it asks for password can you please help. when i use this command to switch user no password is required 1) sudo su - bilbtf42 when i use 2) sudo su - bilbtf42 cp file1 direcotry1/file1 ... (3 Replies)
Discussion started by: blackeyed
3 Replies

10. UNIX for Dummies Questions & Answers

sudo not allow User to run sed

Hello, As recommended by the moderators I will start my questions here... I am a little confused by my Linux (CentOS/RHEL) distribution's sudo mechanism. Or perhaps I just do not know how to use sudo. I can run a sed command as the root user but it fails to write a root-owned directory... (6 Replies)
Discussion started by: duderonomy
6 Replies
Login or Register to Ask a Question