AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  how can I su to root in my script?

    Posted Fri September 07, 2007 09:17 AM

    Originally posted by: SystemAdmin


    I have tried the following but I get "Cannot su to "root" : Authentication is denied." without even asking for the password.

    for remote_h in ServerA ServerB
    do
    ssh $remote_h su - # Here I want the script waits till I put in the password.
    whoami >> result.txt
    done

    Thanks
    #AIX-Forum


  • 2.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 09:23 AM

    Originally posted by: orphy


    Why not just run the for loop as root?
    Orphy
    #AIX-Forum


  • 3.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 10:19 AM

    Originally posted by: SystemAdmin


    > I have tried the following but I get "Cannot su to
    > "root" : Authentication is denied." without even
    > asking for the password.
    >
    > for remote_h in ServerA ServerB
    > do
    > ssh $remote_h su - # Here I want the script to wait
    > # until I put in the password.
    > whoami >> result.txt
    > done

    ssh will normally prevent remote login as root.
    I can think of no valid reason you would wish to
    give unlimited (root) access to a remote entity
    otherwise unidentified.

    In general, good administrative practice avoids
    the use of root access, in favor of offices
    (fictious users that own limited sets of related
    files/processes), monitored privelege tools (e.g.
    sudo(8)), and capabilities (see capabilities(7)).

    Warning,
    #AIX-Forum


  • 4.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 10:38 AM

    Originally posted by: SystemAdmin



    We are not allowed to use sudo or logon to root directly.
    I need to copy my script into 30 servers(needs root) and I do not want to it one
    by one. Is there anyway that I can do this?
    #AIX-Forum


  • 5.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 11:05 AM

    Originally posted by: orphy


    Is this a script that you would run as root or that it goes into
    a directory that only root can write to? If not, simply scp the
    script to those 30 servers using your own login. If not, try
    $ su -
    1. for remote_h in ServerA ServerB
    do
    echo $remote_h
    scp -p <script> $remote_h:/<script_dir>
    done
    Orphy
    #AIX-Forum


  • 6.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 11:06 AM

    Originally posted by: SystemAdmin


    > We are not allowed to use sudo

    Sorry to hear it. sudo(8) with explicit priveleges
    configured is my preferred safety net.

    > or logon to root directly.

    Except for operating system and hardware installation/removal,
    it has been years since I logged in directly as root.

    > I need to copy my script into 30 servers(needs root)
    > and I do not want to it one by one.
    > Is there anyway that I can do this?

    Ask if you can use install(8)
    which allows files to be copied into
    pre-approved directories according
    to other easily configured limits?

    #AIX-Forum


  • 7.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 11:38 AM

    Originally posted by: SystemAdmin



    Thanks for the answers.
    The scirpt goes into a directory that only root can write to and should be un as root.
    So I guess I have to copy them into my home directory and move it manualy???
    #AIX-Forum


  • 8.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 12:21 PM

    Originally posted by: orphy


    No! I assume that you could become root on the box where your script is
    since you are trying to su to root on those 30 boxes. If you indeed can
    be root on the box with the script, simply become root there and scp the
    script to each of the 30 servers. Assuming that ssh is put in place right,
    you should not get prompted for any password.

    For look at the install command, do "man install" or look here:

    http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds3/install.htm
    Orphy
    #AIX-Forum


  • 9.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 11:39 AM

    Originally posted by: SystemAdmin


    I will check to see if we can use install(8). thanks
    #AIX-Forum


  • 10.  Re: how can I su to root in my script?

    Posted Fri September 07, 2007 11:45 AM

    Originally posted by: SystemAdmin


    Sorry , what do you mean by install(8)
    #AIX-Forum