title: Shell script to create linux users where username and password are read from a config file
body: <p>I am trying to develop a shell script which creates new users in linux machine. Where username and password are fetched from a config file. Can somebody help me to create a script which creates users with all the usernames in the config file.</p>
  
  <p>My config file contains (myconf.cfg)</p>
  
  <pre><code>username="tempuser"
  password="passXXX"
  
  username="newuser"
  password="ppwdXXX"
  .....
  .....
  
  username="lastuser"
  password="pass..."
  </code></pre>
  
  <p>Using a script I am trying to create users with above listed username and password. The script is:</p>
  
  <pre><code>#!/bin/sh 
  
  echo "Reading config...." &gt;&amp;2
  . /root/Downloads/guest.cfg
  
  pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
  
  sudo useradd -m -p $pass $username -s /bin/bash
  </code></pre>
  
  <p>I am able to create only 1 user with this script (ie lastuser). Can somebody help me to modify the script and config file so that it will create all the users mentioned in the config file. My aim is to keep the script intact and make changes to the config file only. The script should be able to create 'N' number of users listed in the config file.</p>
  
  <p>Thanks in advance.</p>