## Execute this in master in the presence of /share/apps/configrepo/users_data/userpass.latest.dat ## All users in the list will be added to all nodes, including the master /share/bin/pdsh_sshreachable > /dev/null hosts=$(cat /share/tmp/ssh-reachable.dat) #for i in $hosts # 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 pdsh -R ssh -w ^/share/tmp/ssh-reachable.dat $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