I want to check via BASH if root access on a certain server is possible without a ssh-key. So the script should check if you have access without SSH key or not. Here is my attempt: (pseudocode)
/usr/bin/ssh -o BatchMode=yes -o PreferredAuthentications=password if [[ "$?" == "255" ]]; then echo "root access possible without key" else echo "not possbile" fi
But this code does not work simply because the error code is always the same. No matter if the Server needs a SSH-key or not. My question is now, with which command can I tell if the server needs an SSH key to login or not? Or, which command gives me an error code to check it with?
My goal is to search the entire local network for servers that do not yet use an SSH key