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.

1 Answer 1


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? Commented Jul 20, 2018 at 6:54
  • 1
    @DavidRazdolski Match Users can negate a match Match User *,!admin
    – muru
    Commented Jul 20, 2018 at 6:58
  • @DavidRazdolski That is possible by negation but note that it's broken in certain releases of OpenSSH
    – Amith KK
    Commented Jul 20, 2018 at 7:11

You must log in to answer this question.

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