Automate user creation and password via script
by bigred_247 from LinuxQuestions.org on (#53KQA)
Hi,
I'm trying to automate user creation and password insertion via a script but need some help. I am able to manually do the following:
sudo adduser johndoe
sudo passwd johndoe
and then at the password prompt add the password
Is there a way i can automate this in my shell script? and does the password have to be clear text or is there a way to hide this? FYI, I am using Amazon Linux 2. I'm pretty new to Linux so any help will be much appreciated.
Thanks.


I'm trying to automate user creation and password insertion via a script but need some help. I am able to manually do the following:
sudo adduser johndoe
sudo passwd johndoe
and then at the password prompt add the password
Is there a way i can automate this in my shell script? and does the password have to be clear text or is there a way to hide this? FYI, I am using Amazon Linux 2. I'm pretty new to Linux so any help will be much appreciated.
Thanks.