Welcome to Our Community

Register on JustAnimeForum and start chatting about anime with like-minded people!

Sign Up / Login
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Thank you for the years of fun feel free to join the discord here! Please enjoy the forum for the short time it may be up feel free to make an account here or see what forums you dont need to make an account here
    with love,
    shedninja the sites biggest bug

Linux Question

Discussion in 'Tech Temple' started by Cpt_K3nny, Oct 20, 2016.

  1. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0
    @Kiri @Vashnik


    So I am trying to write a script that would reset the password for about 300 servers for a generic user .

    The issue that I am encountering is we now have several servers that are running linux (This would be a breeze if it was only AIX :confused:)

    So here is my question is there a linux command that would allow me to reset the users password without any interaction from me???

    I read up on the command for passwd for linux But am unable to find anything where it says run command passwd with this parameter to pass the password without prompting....

    Here is a part of my code that I am running right now.
    for A in `cat $SERVERLIST
    do
    OSN=`uname`
    UZER=`ssh $A 'cat /etc/passwd|grep -w $UZER'|wc -l `

    if [[ $OSN='AIX' ]]
    then
    if [[ $UZER -gt 0 ]]
    then
    printf "ssh $A 'echo $UZER:$PASSWORD | /usr/bin/chpasswd -ec'\n" >> UZER_RES_$DTIM.ksh
    fi
    done

    if [[ $OSN='Linux' ]]
    then
    if [[ $UZER -gt 0 ]]
    then
    printf "ssh $A '?????????????" >> UZER_RES_$DTIM.ksh
    fi
    done


    Any input would be of great help.
     
  2. Vashnik Guest

    『   』
    Rank:
    Rank:
    Ratings:
    +0 / 0 / -0
    I'm not familiar with password resets in Linux, so I used Google to look around... one solution was using
    usermod --password PASSWORD USERNAME
    But it requires a pre-encrypted password string that you would have to generate.

    Another one that I found offered a tutorial: http://www.systutorials.com/39549/changing-linux-users-password-in-one-command-line/
    And this site says that you can use this in a bash script.

    You'll probably want to try those on a virtual Linux installation to see which one works better for you though.
     
    • Like Like x 1
  3. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0

    Thanks Vashnik,
    The usermod --password PASSWORD USERNAME command worked.

    I was already sending the encrypted password through for AIX so this command was exactly what I needed!!!

    Thanks again for the input script works like a charm!
     

Share This Page