LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-08-2005, 02:24 PM   #1
JordanH
Member
 
Registered: Oct 2003
Location: Toronto, Canada
Distribution: Ubuntu, FC3, RHEL 3-4 AS Retired: SuSE 9.1 Pro, RedHat 6-9, FC1-2
Posts: 360

Rep: Reputation: 30
execute a script as a different user


Hi All,

I was asked a question today that I can't seem to answer at the moment. My colleague wants to know how he can run a script as UserB from UserA. For example, if he was doing this process manually he would:
1. su - UserB
2. Enter password
3. Run commands as UserB
4. Exit back to UserA shell
However, su as far as I know doesn't accept passwords other than from a local tty. sudo also won't accept a piped in password and rexecd may not be running or available.

So my question to you guys is, how can I help him automate this process?

I'm scratchin' my head.
J.
 
Old 02-08-2005, 02:27 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Take a look at sudo. It will let you run applications as other users.
 
Old 02-08-2005, 02:29 PM   #3
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
set up sudo correctly using "NOPASSWD" for whatever command it is and then 'sudo -u userb command'
Set the script owned by userb and chmod it 4750 (adding user A to whatever group owns the script)
If it's an automated thing, put the script in userb's crontab
etc
etc
etc
 
Old 02-08-2005, 02:47 PM   #4
JordanH
Member
 
Registered: Oct 2003
Location: Toronto, Canada
Distribution: Ubuntu, FC3, RHEL 3-4 AS Retired: SuSE 9.1 Pro, RedHat 6-9, FC1-2
Posts: 360

Original Poster
Rep: Reputation: 30
Hi David, thanks for the response. I did check out sudo but I was having problems with entering a password. I appreciate the fast response.

sigsegv has enlightened me... I didn't know there was a NOPASSWD option. I'll pass your suggestions to my colleague and he'll be very happy.

Thanks guys.
J.
Quote:
Originally posted by sigsegv
set up sudo correctly using "NOPASSWD" for whatever command it is and then 'sudo -u userb command'
Set the script owned by userb and chmod it 4750 (adding user A to whatever group owns the script)
If it's an automated thing, put the script in userb's crontab

Last edited by JordanH; 02-08-2005 at 02:50 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute script as user sbassett Fedora 1 04-06-2005 10:30 AM
Cannot execute a script grueugene Programming 15 01-27-2005 04:50 AM
how to execute firewall script as normal user robthebob Linux - Security 5 01-11-2005 04:36 PM
boot script execute command as non-root user wampfler Linux - Security 7 09-24-2004 04:56 AM
How to execute script after login? gmitra Linux - General 2 02-19-2003 11:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration