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 ?


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"

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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