Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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..."
    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
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


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.