Proper way to add a user account via bash script

My solution was provided here: https://unix.stackexchange.com/questions/82923/proper-way-to-add-a-user-account-via-bash-script by Ulrich Schwarz and Joseph R.. The main thing I had to do was add -s /bin/bash to my existing useradd command and remove -p password which expects an encrypted password.

sudo su -c "useradd mynewuser -s /bin/bash -m -g $PRIMARYGRP -G $MYGROUP"

Then do this:

sudo chpasswd << 'END'
mynewuser:password
END

This will work.

sudo adduser myuser --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
echo "myuser:password" | sudo chpasswd

my script which automatically constructs a service account with ssh key login and no password

#add service group/user
addgroup service-runner
useradd devops-service --create-home --shell /bin/bash --groups service-runner
#gpasswd -a devops-service sudo #allowing sudo requires password, and not a good idea for a service account.
mkdir /home/devops-service/.ssh
chmod 700 /home/devops-service/.ssh
cat [email protected] >> /home/devops-service/.ssh/authorized_keys
chown devops-service:devops-service /home/devops-service -R