A script regularly initiates an SSH connection from one server to another, using SSH keys.

However, once, the keys were briefly overwritten. This caused the SSH client to fall back to asking for a password, which had undesired knock-on effects.

Is it possible to instruct SSH to exit if key-based auth fails, and not fall back to asking for a password?

Thanks!

Wodow

link|improve this question

feedback

3 Answers

up vote 4 down vote accepted

If you don't want to globally disable password authentication on your server you can use the -o "PasswordAuthentication no" option on the ssh command line e.g.

ssh -o "PasswordAuthentication no" YourHost
link|improve this answer
Thanks! This is what I was thinking of. – wodow Dec 2 '10 at 11:01
feedback

You can stop password authentication by configuring the ssh daemon. Edit the /etc/ssh/sshd_config file.

#PasswordAuthentication yes

Uncomment and change the above line to "no".

PasswordAuthentication no

Don't forget to restart your ssh daemon!

link|improve this answer
feedback

vi /etc/ssh/sshd_config

# To disable tunneled clear text passwords, change to no here!

#PasswordAuthentication yes

#PermitEmptyPasswords no

PasswordAuthentication yes

change yes to no

:)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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