List of all users that can connect via SSH

tommydrum picture tommydrum · Apr 4, 2013 · Viewed 168.8k times · Source

I recently started looking at my auth-logs and surprisingly found bots from china trying to bruteforce their way in this (didnt try hard). I went all about changing numerous things that bots would never check, and made harder to bruteforce.

My question is:

I am trying to find a list of all users that can log in to my server via SSH. I know that /etc/passwd has a list of all users, but I don't know if any of them (except for 1) can be logged in.

My goal is to only have 1 user that can be logged in, and having that user have a real strong password.

Answer

dave4420 picture dave4420 · Apr 4, 2013

Read man sshd_config for more details, but you can use the AllowUsers directive in /etc/ssh/sshd_config to limit the set of users who can login.

e.g.

AllowUsers boris

would mean that only the boris user could login via ssh.