On Linux (Debian Squeeze) I would like to disable SSH login using password to some users (selected group or all users except root). But I do not want to disable login using certificate for them.

edit: thanks a lot for detailed answer! For some reason this does not work on my server:

Match User !root
PasswordAuthentication no

...but can be easily replaced by

PasswordAuthentication no
Match User root
PasswordAuthentication yes
link|improve this question

80% accept rate
feedback

2 Answers

up vote 15 down vote accepted

Try Match in sshd_config:

Match User user1,user2,user3,user4
    PasswordAuthentication no

Or by group:

Match Group users
    PasswordAuthentication no

Or, as mentioned in the comment, by negation:

Match User !root
    PasswordAuthentication no
link|improve this answer
2  
prefer Match user !root for this case – 84104 Jun 30 '11 at 16:41
Awesome, I didn't know about the Match syntax. One suggestion I would make, though, is if this is a public facing server, I wouldn't allow root login through SSH at all. Probably not a huge deal if it's Internal though.. – Safado Jun 30 '11 at 17:47
I wouldn't allow root login through SSH at all - We use strong root password so this is not real security weakness. – Stepan Jul 4 '11 at 18:35
Strong or not, it can be brute-forced. – SpacemanSpiff Jul 4 '11 at 19:19
@SpacemanSpiff That's what a) strong passwords and b) denyhosts/fail2ban are for. – ceejayoz Jul 4 '11 at 19:56
feedback

There are a few ways that you can do this - first, you could concievably run a second sshd daemon on a different port with different config - its a bit of a hack, but with some chroot work it should work just fine.

Also, you could allow password authentication, but lock the passwords for all but the one user. The users with locked passwords will still be able to authenticate with public keys.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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