#/bin/bash #Assumes you have ssh keys configured hcpu_ip_list=(`echo $HERONS_CPUS | tr ',' ' '`) hcpu_name_list=(`echo $HERONS_CPUS_N | tr ',' ' '`) len=${#hcpu_ip_list[@]} for (( idx=0; idx<$len; idx++ )); do cpu_ip="${hcpu_ip_list[idx]}" cpu_name="${hcpu_name_list[idx]}" if nc -z -G 1 $cpu_ip 22 &>/dev/null; then echo "${cpu_name} ONLINE" if [[ ${cpu_name: -1} == 'F' ]]; then echo "\npass: clearpath\n" eval "ssh-copy-id administrator@$cpu_ip" && echo "Success!" || echo "Failed to move key." else echo "pass: aquabotz" eval "ssh-copy-id student2680@$cpu_ip" && echo "Success!" || echo "Failed to move key." fi else echo "${cpu_name} OFFLINE" fi done