Sudo password in shell file

Tags
file, password, shell, shell scripts, sudo

 
Thread Tools Search this Thread
# 15  
Old 09-19-2018
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
This User Gave Thanks to rbatte1 For This Post:
onenessboy (09-19-2018)
# 16  
Old 09-19-2018
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
This User Gave Thanks to rbatte1 For This Post:
onenessboy (09-19-2018)
# 17  
Old 09-19-2018
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 Smilie
apologies for delayed reply, i was sleeping Smilie

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

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 Smilie

Last edited by onenessboy; 09-19-2018 at 03:26 PM..

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

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