AIX

AIX

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


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  Want to login in AIX using script

    Posted 07/15/09 08:31 AM

    Originally posted by: SystemAdmin


    Hi I am new to AIX..

    I want to create a user in such a way...that whenever I am trying to login using that user..the system SHUTDOWN automatically..

    Please Help me
    #AIX-Forum


  • 2.  Re: Want to login in AIX using script

    Posted 07/15/09 09:02 AM

    Originally posted by: SystemAdmin


    Straightforward.

    Say that you have Username is 'unprivilegeduser' and that user is created, the your /etc/passwd will have an entry like ...

    unprivilegeduser:!:101:101::/home/unprivilegeduser:/usr/bin/ksh

    Just modify this line in /etc/passwd replace the the login shell (last field /etc/ksh is the login shell) with this command /etc/sbin/shutdown

    i.e.
    unprivilegeduser:!:101:101::/home/unprivilegeduser:/etc/sbin/shutdown

    Note: The 3rd and 4th field i have put in some some number in place of userid and groupid, it could be different in your case, this was an example. Again the shell i have mentioned is /usr/bin/ksh (the default in Aix) it might as well be /usr/bin/sh in your case.
    #AIX-Forum


  • 3.  Re: Want to login in AIX using script

    Posted 07/15/09 09:05 AM

    Originally posted by: SystemAdmin


    The username i have used int he example is absurd :)

    You would not shutdown a server if an unprivileged user logs in !!

    You can name it 'bringitdown' instead !!
    #AIX-Forum


  • 4.  Re: Want to login in AIX using script

    Posted 07/16/09 10:08 AM

    Originally posted by: tony.evans


    Have you tested this?
    #AIX-Forum


  • 5.  Re: Want to login in AIX using script

    Posted 07/16/09 01:56 PM

    Originally posted by: SystemAdmin


    Yes, not recently, but with Linux it has worked and this should work the same way with all.

    Unfortunately I do not have any Aix machines at my disposal, the ones I use are servers at workplace which I can not shutdown.

    However I do not see the rationale behind such a login, since it is not advisable. We used to use such tricks during college days on our own linux boxes though only with an intent to experiment all possibilities and not for any feature.

    So I advice not to do such things.
    #AIX-Forum


  • 6.  Re: Want to login in AIX using script

    Posted 07/16/09 06:15 PM

    Originally posted by: SystemAdmin


    I was curious and I do have a test machine laying around, so I tried this.

    $ sudo smitty user
    - Added user "slayer", not an admin, other users can't su, able to log in locally and remotely
    $ sudo cp -p /etc/passwd /etc/passwd.bu
    - just being safe ...

    I logged in as "slayer" remotely to confirm the user account worked as expected, then ...

    $ sudo vi /etc/passwd
    - changed startup shell to "/etc/sbin/shutdown" as described

    Tried logging in as "slayer" again ...

    ...
    3004-009 Failed running login shell.
    Connection closed by foreign host.

    It might work in Linux, but it doesn't work in AIX 5.3 on a 7025-F80 ...
    $ oslevel -s
    5300-08-06-0918
    $
    #AIX-Forum


  • 7.  Re: Want to login in AIX using script

    Posted 07/16/09 07:22 PM

    Originally posted by: shargus


    That's right - it has to be a valid shell as listed in /etc/security/login.cfg:
    *
    • shells The list of valid login shells for a user; chuser and chsh will
    • only change a user's login shell to one of the shells listed
    • here.
    *
    #AIX-Forum


  • 8.  Re: Want to login in AIX using script

    Posted 07/16/09 07:34 PM

    Originally posted by: shargus


    If you use the .profile, you could also do other cool things. Off the top of my head:
    - Ask for confirmation (are you sure you want to shut this server down? really sure?)
    - Write a log file (or use logger to write to syslog)
    - If you log in using ssh, then sshd sets useful environment variables at login, like SSH_CONNECTION and SSH_CLIENT. Use these for access control (only allow login from a certain IP addresses, etc.) Also, write a better log, since you know where they log in from.
    - Use logname to tell if they are logging in directly or su'ing from a different account.
    #AIX-Forum


  • 9.  Re: Want to login in AIX using script

    Posted 07/17/09 01:05 AM

    Originally posted by: SystemAdmin


    That's right I remember seeing the list of valid login shells in Aix, those were Redhat Linux machines when Redhat was absolutely free to use (like Fedora today) and perhaps did not have as many stringent rules.

    The .profile of the specific user would be a good place and again this is provided that the user has read and execute permission on /usr/sbin folder and execute permission on shutdown command.
    #AIX-Forum


  • 10.  Re: Want to login in AIX using script

    Posted 07/16/09 03:17 PM

    Originally posted by: shargus


    Wouldn't it be easier to put the shutdown command in the .profile for that account?

    if the account doesn't have the privilege to run shutdown, maybe use "sudo shutdown"?

    You can also pass parameters along, such as "shutdown -Fr" to reboot, etc.
    #AIX-Forum