You do not have any test to exit after three times around the loop, instead you have a loop which runs three times - not the same thing.
Instead of setting the loop to run three times, I would write an endless loop which breaks on the success condition (exit status zero), and exits after three unsuccessful trips around the loop. To do that we need a loop counter and two tests.
Here is one way to do it:
Code:
loop_count=0
while [ 1 -gt 0 ] ; do
((loop_count++))
echo "Verifying..."
kinit $USER
#Break loop on success
if [ $? -eq 0 ]; then
break;
fi
#Exit with error after third fail
if [ $loop_count -ge 3 ]; then
exit 1;
fi
echo "Please try again..."
sleep 1;
done
#Arrive here only on success within three tries
echo "Continuing..."