I have a shell script that includes the following command:
/usr/local/bin/ssh -q -i /.ssh/id_rsa -l oracle \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-o PasswordAuthentication=no \
${REMOTE_HOST} ${REMOTE_CMD}
The StrictHostKeyChecking=no avoids prompting if the remote host isn’t recognized, while the PasswordAuthentication=no avoids prompting for passwords if the private key isn’t known. However, if someone accidentally sets a passphrase for the private key, I still get a prompt to “Enter passphrase for key”. This can cause the script to hang while waiting for a response, which is a bad thing. Is there some way to avoid the prompt and exit immediately?
ssh -o BatchMode=yes ...will disable passphrase/password querying.