Below is the script which i use to create single user on server(I use another scpect script to copy below script on server and run script),But i want to create multiple user.
So,only once i will enter username on line 4 and it will create multiple user with increment user1,user2 and so on...
#!/bin/bash
#Script to Add User
tail /etc/passwd | cut -d: -f1
read -p 'Please Enter The Username To Add: ' name
echo "$name" > /tmp/userlist.txt
clear
echo -e "Hello $name\nYour Name Is Added To The List."
userfile=/tmp/userlist.txt
username=$(cat /tmp/userlist.txt | tr 'A-Z' 'a-z')
for user in $username
do
useradd $user -N -s /bin/bash
usermod -aG sudo $user
passwd $user
#echo "AllowUsers ${user}" >> /etc/ssh/sshd_config
sed -i "s/tui/tui $user/g" /etc/ssh/sshd_config
sed -i "s/$user.*$user/$user/g" /etc/ssh/sshd_config
sed -i "s/tui/tui $user/g" /etc/security/access.conf
done
echo "=================================="
echo "User $name Have Been Created."
echo "=================================="
tail /etc/passwd | cut -d: -f1