I have below bash script,every time i want to create a user i need to copy this script to server and run it.
Is there any thing we can do so that this script fetches the IP's from a hosts.txt file(running script on multiple server's)one by one and create user on server.Also,we need to be root to run this script.
1.ask for password once and use it in script for rest of the script where ever necessary. 2.login as normal user. 3.become a root user and run the script
#!/bin/bash #Script to Add User read -p 'Please Enter The Username To Add: ' name echo "$name" > /tmp/userlist.txt clear echo -e "Hallo $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 done echo "==================================" echo "User $name Have Been Created." echo "==================================" tail /etc/passwd | cut -d: -f1