I have a for loop that counts and makes changes on servers. Each server has numerous users and I need to perform some simple operations on each user's account. Regardless of what needs to be done, I need to count up for the IP space of each server and for each run of the loop, I need a different username to be used. users.txt contains
usera
userb
userc
My loop looks like
for (( counter=1; counter<99; counter++))
do
if [ $counter -lt 10 ];
then
ssh -o StrictHostKeyChecking=no user@server0${counter}.domain.com mkdir /home/${user}/newdir
else
ssh -o StrictHostKeyChecking=no user@server${counter}.domain.com mkdir /home/${user}/newdir
fi
done
But none of this addresses the $user for each line and I'm not sure of how to best approach it. Ideally the script would use:
ssh -o StrictHostKeyChecking=no [email protected] mkdir /home/username/newdir
Thank you for any help or guidance you can offer.
ssh ... ; mkdir /home/username/newdir? Did you mean to run themkdircommand on the remote server? Because the;terminates thesshcommand and themkdirruns on your machine.