Automatically add user to Ubuntu Linux and set password
Posted on December 23rd, 2008 in Development | No Comments »
I was wondering how to create a user on my system without requiring a prompt or CLI access. The following script is the result:
#!/bin/bash UADD=/usr/sbin/useradd OPENSSL=/usr/bin/openssl SHELL=/bin/bash # Generate 12 characters long password and print it. PASS=`$OPENSSL rand -base64 12` echo $PASS # Make the password usable for the useradd utility PASS=`mkpasswd $PASS` # Create the user $UADD -s $SHELL -m $1 -p $PASS
Oh, and of course this is released into the public domain. Use it the way you like it.