Information Security Stack Exchange is a question and answer site for information security professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  1. I have configured sshd on an Ubuntu server to use key authentication and it is working fine.
  2. I had to disable password authentication for key authentication to work.
  3. Server is always accessed via remote terminals or putty.

Now all user accounts are able to login with the authentication key and passphrase. But now I want to create only one new user without key authentication. So how should I go about doing this in such a way that does not hamper other users who are using key authentication.

share|improve this question
It is not correct that you must disable password authentication for key authentication to work. However, disabling password authentication is usually a good thing anyway (unless you have a lot of trust in your users to choose excellent passwords -- and possibly even then). In any case, you have received good answers about how to disable password authentication for all but a single user, and that is probably the right strategy to follow. – D.W. Aug 21 '12 at 6:51
up vote 34 down vote accepted

You can use Match in sshd_config to select individual users to alter the PasswordAuthentication directive for. Enter these Match rules at the bottom of sshd_config file ( generally /etc/ssh/sshd_config )

Match User root,foo,bar
    PasswordAuthentication no
Match User Rishee
    PasswordAuthentication yes

This would give root, foo and bar key authentication, and Rishee password authentication.

An alternative is to match by negation, like this:

PasswordAuthentication no
Match User !root
    PasswordAuthentication yes

In this case, everyone except root gets password authentication.

You can also match by group:

Match Group usergroup
    PasswordAuthentication no

Reason for entering Match at the bottom of the file:

If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another >Match line or the end of the file

share|improve this answer
I didn't even know that was possible, cool :D – Lucas Kauffman Aug 2 '12 at 11:19
@Polynomial I created a user called auditor with a password and then I updated the /etc/ssh/sshd_config with the below entry. : <br />Match User auditor PasswordAuthentication yes <br /> then tried to connect to the server with putty it said server refused connection No authentication method supported. – Rishee Aug 2 '12 at 12:07
I'd need to see the full set of authentication rules to help really. Could you stick it on a pastebin for me? Though, at this point, your question might be better suited to Ask Ubuntu. – Polynomial Aug 2 '12 at 12:12
@Polynomial Pastbin for sshd_config I have also asked it on askubuntu + Superuser + ServerFault – Rishee Aug 2 '12 at 13:06
@Rishee you need to restart sshd for the changes to take effect. – Maerlyn Aug 2 '12 at 14:56

You can enable password and key-authentication at the same time, they are not exclusive.

share|improve this answer
But they're not selective. (EG. Not multifactuor) It allows multiple single factors. Though redhat fixed that – Ori Aug 3 '12 at 3:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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