Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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