5

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

wodow
  • 590
  • 1
  • 6
  • 18

3 Answers3

11

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!

Khaled
  • 36,533
  • 8
  • 72
  • 99
8

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
user9517
  • 115,471
  • 20
  • 215
  • 297
0

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

:)

Rajat
  • 3,349
  • 22
  • 29