Help with su | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Help with su

UNIX for Advanced & Expert Users


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-26-2009
Taranjeet Singh Taranjeet Singh is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 22 December 2009, 1:57 PM EST
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Help with su

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.

Please guide me further...

Thanks...
Sponsored Links
    #2  
Old 02-26-2009
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 26 November 2014, 5:04 PM EST
Location: Saskatchewan
Posts: 19,943
Thanks: 848
Thanked 3,420 Times in 3,205 Posts
It is very difficult to redirect a password into su and this is intentional. Storing passwords and automatically logging into accounts is very dangerous and often a bad idea.

sudo can be configured to login without passwords, it is very flexible; but be careful to only give such permissions in a very limited and specific way.
Sponsored Links
    #3  
Old 02-26-2009
Taranjeet Singh Taranjeet Singh is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 22 December 2009, 1:57 PM EST
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Help with su

Hi,

I already tried using sudo but i don't have access to it,so that's why i am compelled to use it with su..

Is there no way out by which we can pass the password along with the username while using su....
    #4  
Old 02-26-2009
frozentin frozentin is offline
Registered User
 
Join Date: May 2008
Last Activity: 27 December 2010, 11:09 AM EST
Location: Vienna, VA + Bombay, India
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
What you could do is make "root" the owner of the file (and chmod 500), and then run your script. It won't prompt "root" for passwords.
Sponsored Links
    #5  
Old 02-27-2009
Taranjeet Singh Taranjeet Singh is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 22 December 2009, 1:57 PM EST
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Help with su

Hi,

I can't make the roort owner of the file as I don't have rights to do so.

Is there no other alternative to do so???

I have heard about expect utility ,but it also works for root only.

Can anyone give any solution to the problem ?

thanks in advance...
Sponsored Links
    #6  
Old 03-02-2009
Taranjeet Singh Taranjeet Singh is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 22 December 2009, 1:57 PM EST
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Help with su

Can anyone help me for the above??

I am unable to implement the logic of expect in my script.

Any help of whatsoever magnitude may prove very useful..

Thanks in advance...
Sponsored Links
    #7  
Old 03-02-2009
Autocross.US's Avatar
Autocross.US Autocross.US is offline
Registered User
 
Join Date: Nov 2008
Last Activity: 10 October 2010, 2:11 PM EDT
Location: Chesapeake, VA
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Instead of using su or sudo, you could use ssh with key-based authentication. See my reply on a similar thread here:

http://www.unix.com/unix-advanced-ex...#post302274343
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -4. The time now is 09:33 PM.