0

I have a script that will run on host1 but will make some ssh calls to host2. If host1->host2 passwordless ssh is not setup, the script will not work. How do I detect whether passwordless ssh is setup or not?

If I do something like:

`ssh host2 ls`
if [[ $? -eq 0 ]]; then 
    echo "Passwordless SSH works..."
else
    echo "Don't have passwordless SSH"

but passwordless ssh isn't there, it hangs at the password prompt.

Basically, I want to call ssh but have the client die if the server requests a password.

3

Use the PasswordAuthentication option via the '-o' parameter to ssh. That should make the connection fail if it wants a password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.