- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- su with password in a script.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:08 AM
11-14-2001 10:08 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:15 AM
11-14-2001 10:15 AM
Re: su with password in a script.
You can't do this in a simple shell script. The 'su' (unless you are root) will prompt you via your terminal, for a password.
You could use 'expect' however. See here:
http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.31/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:15 AM
11-14-2001 10:15 AM
Re: su with password in a script.
Also, you can use the setuid bit on the script.
chown username scriptname
chmod 4555 scriiptname
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:15 AM
11-14-2001 10:15 AM
Re: su with password in a script.
Thanks
ct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:19 AM
11-14-2001 10:19 AM
Re: su with password in a script.
I guess using expect you can do that. su to A, then su to B and give password. I haven't used the same myself, but it works interactively with the script.
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:21 AM
11-14-2001 10:21 AM
Re: su with password in a script.
Why don't you run a blanket script from user root, running first script A, then B? Or if the su you are trying to do is in the middle of a script, break it up into 3 scripts?
i.e.
#!/bin/sh
# Run this script as root
su - user1 -c "/your/path/here/scriptA.sh"
su - user2 -c "/your/path/here/scriptB.sh"
su - user1 -c "/your/path/here/scriptC.sh"
Cheers,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 10:24 AM
11-14-2001 10:24 AM
Re: su with password in a script.
in userB's home directory create a ".rhosts" file
.rhosts
then as userA
remsh
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2001 07:30 AM
11-15-2001 07:30 AM
Re: su with password in a script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2001 08:04 AM
11-15-2001 08:04 AM
Re: su with password in a script.
Soapbox time!
Personally and for security reasons, I don't like the idea of a script (or any file) containing a password in clear text. Neither should any user know another user's password. Granted, some group of users (dba for example) need to know a password for a common account (perhaps oracle) but that account should only be accessible by su'ing to it.
Users should have passwords. Don't even think of removing it.
Harry's remsh hack can be done but unfortunately it is effectively the same as giving userA the password for userB because userA could "remote" log in as userB any time he wanted to. You no longer have any accountability. Auditors don't like that kind of stuff.
The only secure solutions I see:
1. Give the user permissions to do what needs to be done so that he no longer needs to su.
2. Run the script as root.
3. Best choice I believe and as indicated by others - suid script.
Don't use 4555 because that would let anyone run the script. 4550 with the group being a secondary group for only the user(s) allowed to run the script should work.
Told 'ya I was on my soapbox! These are my opinions and are guaranteed to be different from the opinions of many other admins!
Darrell