su - root script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting su - root script
# 1  
Old 10-05-2006
su - root script

Hi all,

I'm configuring a script to su from a normal user to root. What is the exact syntax to su to root + password provided inside the script?

For example: su - root will require password, I would want this password hardcoded inside the script

Thanks.
# 2  
Old 10-05-2006
Hardcoding root passwords inside a script is a bad idea. For the script to be executable, it has to be readable by users, and any user that can read this script can see the root password. And that is not a great idea.

It probably would better to put a setuid c wrapper around this shell script so that you don't have to do su to root.
# 3  
Old 10-05-2006
If you need to run the script on a regular basis, put it in "root cron"

Have you though about installing "sudo"
This will allow you to configure who can and can not run what scripts or commands as root with out the use of the root passwd and restrict the population of the root passwd to other users. Basicly you can get back control over the root account.

Last edited by Andrek; 10-05-2006 at 08:57 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Running a script as root in the script

hi all, i think i have got the solution for this but want to run it past you guys first when i run a script sometimes its necassary to sudo to root so it can create users, chmod etc etc, the normal way for me doing this is just to simply run the script as root but i have created a user... (11 Replies)
Discussion started by: robertkwild
11 Replies

2. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

3. Red Hat

Root password expiry script

Hi Guys In red hat linux server is there a way to alert via email when the root password is about to expire ? As per security policy in our environment root password will expire in 90 days. Example : It would be better if we receive a email on 7th november stating that the root password... (1 Reply)
Discussion started by: newtoaixos
1 Replies

4. Shell Programming and Scripting

Switch between root and user in the same script.

I am writing a korn shell script where i need to switch to root in between and again exit from root to normal user and continue other commands. Is that possible to switch between these two in the same script? (1 Reply)
Discussion started by: santosh2626
1 Replies

5. Solaris

Migration of system having UFS root FS with zones root to ZFS root FS

Hi All After downloading ZFS documentation from oracle site, I am able to successfully migrate UFS root FS without zones to ZFS root FS. But in case of UFS root file system with zones , I am successfully able to migrate global zone to zfs root file system but zone are still in UFS root file... (2 Replies)
Discussion started by: sb200
2 Replies

6. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

7. Shell Programming and Scripting

Shell script ,being root

It needs be root for some command and not for other commands. fdisk -l ls -l cd /etc For fdisk -l need root password. After fdisk -l i want to be again a normal user. How can i this with shell script? (4 Replies)
Discussion started by: cola
4 Replies

8. Shell Programming and Scripting

root executes a script as another user

Hi All, Am using the below command to start my application using the root user su - bin -c "/home/bin/test/start.sh" but am getting the error becaue i have set some environment varibales in bin's .profile when i execute the command start.sh by logging directly into bin account it's... (9 Replies)
Discussion started by: ravi.sri24
9 Replies

9. Shell Programming and Scripting

root executes a script as another user

we have this script that stops, starts and monitor process scheduler. prcs_control. this script runs perfectly when executed by ps_user. we are now creating a new script that will run this script and is executed by root. this script needs to execute the prcs_control as ps_user because root can... (1 Reply)
Discussion started by: tads98
1 Replies

10. UNIX for Dummies Questions & Answers

Run non-root script as root with non-root environment

All, I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)
Discussion started by: bubba112557
2 Replies
Login or Register to Ask a Question