I'm trying to check all servers in an array to see whether they are configured with the SSH password-less trust or not.
If some are not, I'd like to print the server details, and keep looping through the array elements (ips) until all have been checked.
(I want to have the opportunity to print all the erroneous ones before exiting.)
I tried the following approach, but it exits the loop after it meets the first unconfigured server:
for svr in "${table[@]}"
do
SSH=$(ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no $svr echo)
if $(echo [ $? -ne 0 ])
then echo "Trust is not configured for ${table[$svr]}"
exit "$SOME"
else
:
fi
done
What am I doing wrong?