How to automatically add user account AND password with a Bash script?

前端 未结 19 660
北荒
北荒 2020-12-07 06:53

I need to have the ability to create user accounts on my Linux (Fedora 10) and automatically assign a password via a bash script(or otherwise, if need be).

It\'s eas

19条回答
  •  囚心锁ツ
    2020-12-07 07:23

    From IBM (https://www.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.cmds1/chpasswd.htm):

    Create a text file, say text.txt and populate it with user:password pairs as follows:

    user1:password1
    user2:password2
    ...
    usern:passwordn
    

    Save the text.txt file, and run

    cat text.txt | chpassword
    

    That's it. The solution is (a) scalable and (b) does not involve printing passwords on the command line.

提交回复
热议问题