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.

1 Answer 1

3

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

1
  • @Jonathan You can even disable PasswordAuthentication in ssh configuration file so that it will not ask for password. Commented May 9, 2021 at 2:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.