setup sudo for cmd exec w/o password

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat setup sudo for cmd exec w/o password
# 1  
Old 06-02-2011
setup sudo for cmd exec w/o password

i need to set up a user to execute a restricted command as another user and to be able to do so without entering a password. I understand the security concerns but let's not go there, unless you are really compelled to do so... The directive to permit is that I believe should work and did add to the end of the /etc/sudoers file is:
Code:
user1        ALL=(user2)  NOPASSWD: /bin/kill

but it appears not to work as after entering
Code:
sudo -u user2 -i /bin/kill -15 1234

I get prompted for user1's password.

Any suggestions appreciated, including why the above does not work.

Thanks...
# 2  
Old 06-03-2011
twk,

are u sure the proccess (1234) is running as user2. can u list out the sudo -l output from user1
# 3  
Old 06-03-2011
You shouldn't use "-i" as parameter to sudo, because this flag instructs sudo to run the command as a login shell like this:
Code:
/bin/bash -c /bin/kill 1234

instead of
Code:
/bin/kill 1234

and you only gave sudo permissions to /bin/kill, not to /bin/bash.

So you should run your sudo command as follows, without the "-i":
Code:
sudo -u user2 /bin/kill -15 1234

Let us know how it works for you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

SSH password less setup asking for password

Hello Experts, when I am trying to connect my target server through sftp after creating ssh password less setup, it is asking for passowrd to connect. to setup this I followed below process: -->generated keys by executing the command "ssh-keygen -t rsa" -->this created my .ssh directory... (9 Replies)
Discussion started by: Devipriya Ch
9 Replies

2. AIX

UNIX cmd to check for non expiry type password

Hi, Here's the version of unix that we are working on. > uname -a AIX yyyyyyyy 1 6 00F613E24C00 @:on(cluster303)/iishomea/kmani00-> i have application id: aaabbb Now i need to check whether the password for the application id set to non expiry type or not. Moreover, with that unix... (3 Replies)
Discussion started by: kmanivan82
3 Replies

3. Shell Programming and Scripting

How to setup a password less ftp??

hi, i want to setup a password less FTP to a remote server so that i can ftp to a remote server without the password. i have setup a passwordless ssh and i am able to use scp commands to connect to the remote server without asking for the password. but when i try to ftp to the same remote... (6 Replies)
Discussion started by: Little
6 Replies

4. UNIX for Dummies Questions & Answers

How to hide password when using echo cmd?

Hi Am using unix Aix Ksh I need to hide the password using echo cmd Connecting the database and fetching ip_address and password from one table. greping the IP_address and password using two variable IP_addr Pawd Then Used echo cmd echo " connecting to $IP-addr and $Pawd" ... (3 Replies)
Discussion started by: Venkatesh1
3 Replies

5. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

6. Shell Programming and Scripting

-exec cmd in ksh script

Hi, I discovered the following single-line script works very well to cp a large number of files from a source directory to a destination directory while avoiding the "argument list too large" error: # cpmany - copy large number of files # Takes two parameters - source dir, destination dir... (14 Replies)
Discussion started by: Tanuka
14 Replies

7. UNIX for Advanced & Expert Users

Setup SUDO For a User on Linux Server

Hello! Can anyone please assist: Question: On Linux Server I have created two users John and Matt. I want to give both the users the ability to run 'more' and 'tail -f' commands on the log file in the directory /var/log/test.log. I do not want to give them SU rights. Can any one please... (6 Replies)
Discussion started by: sureshcisco
6 Replies

8. Shell Programming and Scripting

password getting displayed using sudo

Hi While doing the following command password is gettin dispalyed : ssh <host> "sudo command ; exit" .... while i type my password for 2nd its gettin displayed ... i tried stty -echo and stty echo ... still i am havin problem..:confused: (1 Reply)
Discussion started by: ningy
1 Replies

9. AIX

sudo setup

I am working on setting sudo on a few AIX servers and wanted to know how to give users root access without allowing them access to the sudo logs, sudoers files and the /etc/security directory. (3 Replies)
Discussion started by: daveisme
3 Replies

10. AIX

Sudo ask for password

Hello I have a partition with Aix 5.3 and I install sudo I put the commands that I want to use x user and I put the option that donkask for password. But when I run with this user and I try to run that commands. ask me for a password. I put this line for no ask for password with that... (2 Replies)
Discussion started by: lo-lp-kl
2 Replies
Login or Register to Ask a Question