Change user password via a script - Aix

This is a discussion on Change user password via a script - Aix ; Hello, for preventing a user with no password to connect on a software during night process, i want to apply him a password via a script. For that, i do the following working commands : echo "user asswd" | chpasswd ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Change user password via a script

  1. Change user password via a script

    Hello,

    for preventing a user with no password to connect on a software during
    night process, i want to apply him a password via a script. For that, i
    do the following working commands :
    echo "userasswd" | chpasswd
    pwadmin -c user

    I can't deactivate the account because people working during the night
    may need to connect with that account for their night tasks

    At the of the night, i want to delete the password for the account via a
    script. The problem is that chpasswd dont accept blank passwd.

    Any Ideas ?

  2. Re: Change user password via a script

    Patrick Tonnerre writes:

    > At the of the night, i want to delete the password for the account via
    > a script.


    You do realize this is a Bad Idea(TM) ?

    > The problem is that chpasswd dont accept blank passwd.


    And with a good reason.

    > Any Ideas ?


    You could script this with 'expect' ...

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: Change user password via a script

    Sorry for reviving this old thread.

    I was searching for this exact solution to create a passwordless user,
    and since this post is the first result when you search google for
    'chpasswd blank password', I though I'd share my solution.

    Due to restrictions in PAM, if you get an error message if you try a
    blank password in chpasswd:

    Code:
    # useradd user
    # echo "user:" | chpasswd
    
    No password supplied
    No password supplied
    No password supplied
    chpasswd: (user user) pam_chauthtok() failed, error:
    Authentication token manipulation error
    chpasswd: (line 1, user user) password not changed
    To avoid this error, you have to bypass PAM with the -e flag:

    Code:
    # echo "user:" | chpasswd -e
    Be careful, the -e flag expects passwords to be provided in encrypted form.
    Since the encryted form of a blank password is also blank, it works!
    Hope this helps somebody.

    By the way, this is indeed a Bad Idea(TM)!
    Be careful.

+ Reply to Thread