Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Sudo password in shell file

Tags
file, password, shell, shell scripts, sudo

Login to Reply

 
Thread Tools Search this Thread
# 15  
Old 1 Week Ago
You don't add oracle to the wheel group. You need to allow your account to execute as oracle. Say your account is bob, then the entry in /etc/sudoers (or perhaps under /etc/sudoers.d/* could be something like:-
Code:
bob   ALL=(oracle)   NOPASSWD:   /path/to/you/script

..... and on the command line as bob you should be able to run:-
Code:
sudo -u oracle /path/to/your/script



Does that help?



Robin
The Following User Says Thank You to rbatte1 For This Useful Post:
onenessboy (6 Days Ago)
# 16  
Old 1 Week Ago
Just thinking about this in the wider question, you might (on you local machine) have to do this:-
Code:
ssh bob@server "sudo -u oracle /path/to/your/script"

.... or perhaps:-
Code:
ssh -t bob@server "sudo -u oracle /path/to/your/script"

.... or even:-
Code:
ssh -tt bob@server "sudo -u oracle /path/to/your/script"

This would open the SSH connection, sudo run the script and exit back to your local machine. The additional of one or two -t might be needed to make it set up a terminal connection else sudo might refuse to run.





Robin
The Following User Says Thank You to rbatte1 For This Useful Post:
onenessboy (6 Days Ago)
# 17  
Old 6 Days Ago
Quote:
Originally Posted by rbatte1
Just thinking about this in the wider question, you might (on you local machine) have to do this:-
Code:
ssh bob@server "sudo -u oracle /path/to/your/script"

.... or perhaps:-
Code:
ssh -t bob@server "sudo -u oracle /path/to/your/script"

.... or even:-
Code:
ssh -tt bob@server "sudo -u oracle /path/to/your/script"

This would open the SSH connection, sudo run the script and exit back to your local machine. The additional of one or two -t might be needed to make it set up a terminal connection else sudo might refuse to run.





Robin
First of all, thanks for your patience in answering
apologies for delayed reply, i was sleeping

Superb !..Thanks for great help, I have tested it from local machine to one of the remote ,it running fine ..

But on another remote its not working..just out of curiosity, asking the below question
...is that possible for an admin to restrict a remote user to login without su password authentication (even though I have followed your solution suggestion)...if there is method, then I think I am gonna tell him , if you restrict me I wont work

Last edited by onenessboy; 6 Days Ago at 02:26 PM..
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sudo reads password from a .cfg file dellanicholson UNIX for Dummies Questions & Answers 4 10-01-2015 11:23 AM
Sudo without password Solaris 11.2 akame Solaris 5 10-29-2014 06:57 AM
Sudo -s without password prompt krk UNIX for Dummies Questions & Answers 3 01-04-2013 08:57 PM
Sudo + Nohup = no password? nitrobass24 Red Hat 4 07-30-2012 10:33 AM
ssh foo.com sudo command - Prompts for sudo password as visible text. Help? fluoborate Shell Programming and Scripting 9 11-02-2011 02:18 PM
password in sudo script pua06 Shell Programming and Scripting 5 07-18-2011 12:30 AM
password getting displayed using sudo ningy Shell Programming and Scripting 1 04-08-2010 05:46 PM
Sudo ask for password lo-lp-kl AIX 2 06-03-2009 06:16 PM
verify sudo password mdpalow Shell Programming and Scripting 0 12-20-2007 09:53 PM
sudo in OS X shell script without password prompt?? Brad_GNET UNIX for Dummies Questions & Answers 1 07-29-2005 06:36 PM


All times are GMT -4. The time now is 06:52 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password