Sudo reads password from a .cfg file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sudo reads password from a .cfg file
# 1  
Old 09-24-2015
Sudo reads password from a .cfg file

cleanwork /saswork removes sas orphanded processes in the saswork directory. Subdirectories under sasem are sas94, sas92 and sasworks .

I am getting the following error messages:
1.
'/usr/bin/sudo -S apt-get update <~/opt/SiM/pos/ps/db_auth.cfg /sasem/sas92/sashome/sasfoundation/9.2/utilities/bin/cleanwork /sasworks'

line 69 '/usr/bin/sudo -S apt-get update <~/opt/SiM/pos/db_auth.cfg /sasem/sas92/sashome/sasfoundation/9.2/utilities/bin/cleanwork /sasworks: A file or directory in path does not exist

2.
'/usr/bin/sudo -S apt-get update <~/opt/SiM/pos/db_auth.cfg /sasem/sas94/sashome/sasfoundation/9.4/utilities/bin/cleanwork /sasworks'


line 76 '/usr/bin/sudo -S apt-get update <~/opt/SiM/pos/db_auth.cfg /sasem/sas94/sashome/sasfoundation/9.4/utilities/bin/cleanwork /sasworks: A file or directory in path does not exist


3.
-S apt-get update is not reading in the password from the db_auth.cfg file.

4.
How the sudo -S apt-get update <~/opt/SiM/pos/db_auth.cfg syntax works is when the sudo command prompts for a password, the password is read from db_auth.cfg.

5.
db_auth.cfg contents are as following (encrypt the password) :
DB_PASSWD="Swxftyi"
DB_PASSWORD=$(eval echo ${DB_PASSWD} | base64


6.
Code:
db_auth.cfg
DB_PASSWD="Swxftyi"
DB_PASSWORD=$(eval echo ${DB_PASSWD} | base64

7.
Code:
function cleanwork 
{
 set -x
    '/usr/bin/sudo  -S apt-get update <~/opt/SiM/pos/db_auth.cfg     /sasem/sas92/sashome/sasfoundation/9.2/utilities/bin/cleanwork /sasworks'
set +x
}

function cleanwork94
{
 set -x
    '/usr/bin/sudo  -S apt-get update <~/opt/SiM/pos/db_auth.cfg     /sasem/sas94/sashome/sasfoundation/9.4/utilities/bin/cleanwork  /sasworks'
set +x
}

./cleanwork

./cleanwork94

# 2  
Old 09-25-2015
sudo will not read a password from file, ever. It's designed to prevent you from doing what you're trying to do, because it's a terribly insecure idea.

Configure sudo to allow you to run that specific script without a password instead.
# 3  
Old 09-25-2015
If I manually type the follow script in a command prompt, it will work but I am prompted for a password.

The following is an example of the script in a command prompt:

Code:
  cd  /sasem/sas92/sashome/sasfoundation/9.2/utilities/bin/
$ ./cleanwork /sasworks

I added the code to a shell script but I am getting the following error
message: sasworks cannot be found

Here is my code:
Code:
!#bin/bash
sasadm ALL = NOPASSWD: ALL

echo cleanwork='/usr/bin/sudo   /sasem/sas92/sashome/sasfoundation/9.2/utilities/bin/cleanwork /sasworks'


echo cleanwork94='/usr/bin/sudo   /sasem/sas94/sashome/sasfoundation/9.4/utilities/bin/cleanwork /sasworks'

./$cleanwork

././$cleanwork94

# 4  
Old 09-26-2015
Does the file "/sasworks" (in the file systems' root!) really exist? Shouldn't it be local to e.g. "sasem"?

Sure your "shebang" doesn't give an error?

The second line looks like a "sudoers" entry. Sure you want it there?
# 5  
Old 10-01-2015
Quote:
Originally Posted by dellanicholson
I added the code to a shell script but I am getting the following error
sudo does not work that way.

Put sudo directives in sudoers. You will need administrator access to do so.
This User Gave Thanks to Corona688 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sudo password in shell file

Hi all, I have a script like this, where i am trying to login into oracle db via ssh and do a account unlock. #!/bin/sh ip=$1 os_user=$2 key=$3 ou_user=$4 ou_pass=$5 unlock_user=$6 ssh -i $key $os_user@$ip sudo -u $ou_user -p $ou_pass -- i am getting error here...its not taking... (16 Replies)
Discussion started by: onenessboy
16 Replies

2. Solaris

Sudo without password Solaris 11.2

Hi guys, I have the strangest issue... might be a huge oversight.. who knows!! :) I am trying to configure a user to use sudo with no password, here is my sudoers configuration file root@isha:~# egrep -v "^$|^#" /etc/sudoers root ALL=(ALL) ALL %wheel ALL=(ALL) NOPASSWD: ALL... (5 Replies)
Discussion started by: akame
5 Replies

3. Red Hat

Sudo + Nohup = no password?

Little confused here When i go to run sudo nohup ./script.ksh & I dont get asked for a password. It starts a process ID, I can see it when i do a ps -ef | grep script. But I dont get an output file from my script, so its not doing anything. What gives? does it have to do the "&" ? ... (4 Replies)
Discussion started by: nitrobass24
4 Replies

4. UNIX for Advanced & Expert Users

problem creating pxelinux.cfg default file

Hi All, I was trying to create pxelinux.cfg/default file in a script that I use for creating backup of bootimage. cat 2>${BACKUB_BOOTIMAGE_ERRINFO} >${pxelinux_cfg_file} <<EOF prompt 1 timeout 0 display boot.msg label restore kernel kernel append root=/dev/nfs... (0 Replies)
Discussion started by: Pkumar Sachin
0 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

password in sudo script

salmo allikm warhmat allah wabrakato i want to do script with sudo like sudo su and want to put password in the script not get from user because i to made it startup when booting and i don't know how put in script for sudo thanks (5 Replies)
Discussion started by: pua06
5 Replies

7. UNIX for Dummies Questions & Answers

Difference between buffered disk reads and cached reads?

I was analyzing the Disk read using hdparm utility. This is what i got as a result. # hdparm -t /dev/sda /dev/sda: Timing buffered disk reads: 108 MB in 3.04 seconds = 35.51 MB/sec # hdparm -T /dev/sda /dev/sda: Timing cached reads: 3496 MB in 1.99 seconds = 1756.56 MB/sec... (1 Reply)
Discussion started by: pinga123
1 Replies

8. 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

9. Shell Programming and Scripting

sudo command with password

Hello everybody, Say I forgot my root password (shit happens, no?) and I'd like to brutally try 100 possibilities to delete a file using sudo. How can I make a script that tries all the passwords? The following doesn't work. Do you have a clue? foo:~$ cat test sudo rm dummy <<< 'password' echo... (1 Reply)
Discussion started by: chebarbudo
1 Replies

10. Shell Programming and Scripting

verify sudo password

edited and removed (0 Replies)
Discussion started by: mdpalow
0 Replies
Login or Register to Ask a Question