superuser without prompting for pswd.


 
Thread Tools Search this Thread
Operating Systems Solaris superuser without prompting for pswd.
# 1  
Old 01-08-2009
Question superuser without prompting for pswd.

I have a korn shell script (main.sh) owned by unix account "A". I want to execute certain lines in the script using another user "B" (with user "B" login profile). I need to do this way for multiple lines to be executed using different unix accounts in main.sh.

I was trying to use "su - <account>" but it prompts me for password in interactive mode. How do I write main.sh script that executes various commands by logging in as different accounts and login profiles. Is there a way to automatically redirect the password for "su" command to accept the password.

Unix is Sun Solaris.
# 2  
Old 01-09-2009
Quote:
Originally Posted by Ashok_107
How do I write main.sh script that executes various commands by logging in as different accounts and login profiles.
You cannot.
Quote:
Is there a way to automatically redirect the password for "su" command to accept the password.
No. (Well, there's a way, but it's the wrong solution.)
  1. Install the sudo package, available at the Blastwave site.
  2. Run visudo (as root) and configure your user to run the script with the NOPASSWORD option:
    Code:
    ashok   ALL=(root)    NOPASSWD: /full/path/to/main.sh

  3. Run it as "sudo /full/path/to/main.sh"

Here's an excellent link describing uses of sudo.

Last edited by otheus; 01-09-2009 at 06:25 AM.. Reason: typos
# 3  
Old 01-09-2009
A method which will usually work if you have a default TCP/IP setup with rlogin and remsh enabled. This approach is a security risk but less dangerous than holding a password in a script. All access will be logged. Don't do this with a root account.

See:
man inetd
man .rhosts

To give user user1 full access to user2.

Under user2 home directory create (or edit) the file called .rhosts with permissions 600 owned by user2.
In the .rhosts file put the line:

localhost user1

Then user1 can then rlogin to account user2:

rlogin localhost -l user2

Also user1 can run commands as user2 using remote shell (the command name for remote shell varies according to unix version):

remsh localhost -l user2 env

remsh localhost -l user2 -n "pwd;ls -la"
# 4  
Old 01-09-2009
Alternatively, you can use the supported pfexec/rbac.

RBAC - Role Based Access Control at OpenSolaris.org
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

How do you make a superuser?

I have just installed Solaris 11. When I turn the computer on I don't want to see a login in screen. I want to automatically be logged in as "SUPERUSER". My research tells me someone is going to tell me that's not wise or safe. I'm not interested in security advice. If someone I know is... (10 Replies)
Discussion started by: kkeevv
10 Replies

2. UNIX for Dummies Questions & Answers

Superuser

Hello! I found this on net: This is the ``prompt''. If you entered you username, or your password incorrectly, you will be greeted by: Login incorrect localhost login: Don't panic, try again. Likely you either mis-typed either your login name, or your password. Try again. You're not... (2 Replies)
Discussion started by: pinklemon
2 Replies

3. Solaris

Solaris superuser login

Hi! Can someone please tell me how to log-in to Solaris as a superuser or as a root? I have tried using "root" as a username, and my superuser password i had set in the terminal for the log-in password but it says "Roles can only be assumed by authorized users". "Permission denied." I'm... (1 Reply)
Discussion started by: CarlosP
1 Replies

4. UNIX for Dummies Questions & Answers

FTP thru Unix doesn't auth usrname & pswd, but Windows app does - why?!

Strange one this... One of our contacts switched FTP servers, a different IP and now using port 2121 instead of 21. Changed the details in a Windows application using the username & password provided and it works no problem. Tried to FTP through Unix and although I can connect to the... (2 Replies)
Discussion started by: macca74
2 Replies

5. UNIX for Dummies Questions & Answers

Resetting remote server SSH pswd?

Hi- I'm trying to access my remote server via my bash shell (mac os x), but have forgotten my SSH pswd. How can I reset my pswd? Thanks for any leads... (1 Reply)
Discussion started by: newmacdev
1 Replies

6. UNIX for Dummies Questions & Answers

SuperUser

Can I create a superuser account in scoadmin? If not how do I do it via command line (0 Replies)
Discussion started by: maconte
0 Replies

7. SCO

pswd change on sco GUI login

Can i change the password on the SCO GUI interface login page and if so how? When I try to login it just goes right back to the login screen. If anyone has any suggestions, please reply. :confused: (3 Replies)
Discussion started by: qphillips
3 Replies

8. UNIX for Dummies Questions & Answers

runing a script as superuser

My first post: in /etc/rc2.d i have a startup script: Script1. if you run #>scirpt1 stop/start from any user other than root you will get u must be supper user to run this script. eventhough the rights are 777. Question: how can i get my user_a be able to run this script to stop and start it... (2 Replies)
Discussion started by: bcheaib
2 Replies

9. UNIX for Dummies Questions & Answers

superuser password change

how can i change the superuser password? the admin left the company, and we want to change the password. to gain su access, i use: # su - password:***** (old password) then, using passwd command it changes my own login password, not the root?? (this is not trying to block anybody's... (4 Replies)
Discussion started by: apalex
4 Replies
Login or Register to Ask a Question