Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm writing a script that requires root access for HP-UX. I was wondering if there was some way to pass in a password to the su root -c command so that the user would not be prompted for a password.

In this circumstance, I cannot use sudo because the command does not exist in HP-UX. Otherwise, I would use the command

echo $PASSWORD | sudo -S <command requiring root privileges>
share|improve this question
2  
Run the script as root instead? Otherwise there's a decent potential for security issue. –  Rob Jun 28 '12 at 17:03
    
Maybe you want to install sudo and use it. Do NOT echo your root password, instead configure sudo to not prompt password %users ALL = NOPASSWD: /scripts/rootscript.sh. –  Sampo Sarrala Jun 28 '12 at 17:52
add comment

2 Answers 2

I was wondering if there was some way to pass in a password to the su root -c command so that the user would not be prompted for a password.

Whether this is possible or not, it's not a good idea. What's the point of having a root password if it's stored in cleartext somewhere?

Instead of incorporating su root -c command in a script, just run the script itself as root:

su root -c script
share|improve this answer
add comment

sudo does exist for HP-UX you just need to install it.

http://h30499.www3.hp.com/t5/Security/How-to-install-and-config-sudo-in-HP-UX-11i-v3/td-p/4602410

hope this helps. This is the easiest way or you could set up ssh keys and ssh back to localhost from that username and it would not require you to enter a password.

SSH authorization key for multiple systems

I agree with above this is a horrible to connect as a user and give an account full root access without issuing a password or locking it down with sudo.

Best of Luck!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.