I was wondering if it would be possible to only force SSH key based authentication to one user (admin) and allow all other users on the system (excluding root, who's ssh login is already disabled in sshd_config) to authenticate via Password.


You can do that by modifying your sshd_config to add:

Match User <username>
    PasswordAuthentication no

You can do the same for groups as well by using Match Group instead

Don't forget to restart sshd after

  • Is there any way to just have that as a catch-all for all users except a certain one? i,e admin? – David Razdolski Jul 20 '18 at 6:54
  • 1
    @DavidRazdolski Match Users can negate a match Match User *,!admin – muru Jul 20 '18 at 6:58
  • @DavidRazdolski That is possible by negation but note that it's broken in certain releases of OpenSSH – Amith KK Jul 20 '18 at 7:11

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.