## Execute this in master or any node in the presence of /share/apps/configrepo/users_data/userpass.latest.dat ## Specify which host is to be targeted. By default, host='c100'. ## All users listed in /share/apps/configrepo/users_data/userpass.latest.dat will be added to the node $host host='c100' for i in $host do cat /share/apps/configrepo/users_data/userpass.latest.dat | while read line || [[ -n $line ]]; do echo '$line' $line username=$(echo $line | awk '{print $2}') uid=$(echo $line | awk '{print $3}') passwd=$(echo $line | awk '{print $4}') command='useradd -u '"$uid"' -g users -p $(echo '"$passwd"' | openssl passwd -1 -stdin) '"$username" echo 'adding user '"$username"' in '"$i" echo $command pdsh -R ssh -w "$i" $command chmod -R 755 /home/"$username" echo $username with uid $uid and passord $passwd have been added to the cluster su - $username -c "yes | ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N '' " su - $username -c "cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys" chmod -R 600 /home/"$username"/.ssh/id_rsa echo '' done done