Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SWITCHING USERS WITHIN A SCRIPT

Status
Not open for further replies.

hubud

Instructor
Oct 18, 2002
123
GB
I need to switch users in a script in order to gain access to a server outside a firewall. User1 calls scripts owned by User2.
User2 is able to run commands outside firewall but User1 can't, so when user1 calls the script authorisation denied occurs.
I have tried:

sudo su - user2<<-EOF
user2password

but it still asks for the password when the file runs. Is there any way around this.

cheers

simmo
 
You could set the setuid bit on the script file, which effectively make the script run as it's owner. Read the man pages on chmod and setuid for more info.

Greg.
 
grega, setuid bit don't work with shell scripts.
hubud, you may have to consider script.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top