2

I am provisioning a machine using packer.

The tool offers shell provisioning functionality so I am able to run whatever shell commands I want.

I would like to disable ssh password login.

Is there a way to do this via a command, rather than ending up writing pattern and line mathing seds for /etc/sshd_config ?

2 Answers 2

4

Yes, it's possible to disable password authentication via the command-line. Simply use the -o flag when running the daemon: sshd -o "PasswordAuthentication no"

2
  • Isn't it sshd -o "PasswordAuthentication no"? I think there is a reduntand whitespace in your command
    – pkaramol
    Sep 6, 2018 at 12:43
  • Oops, yes it is. Sep 6, 2018 at 12:44
0

SSH has support for keys. If you set up private and public keys there is no need to use a password.

This means you are not disabling the password login but you are just using a different method to authenticate against the machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .