Check users and groups in sshd_config and sssd

Use this oneliner to quickly list who all is allowed in ssh and sssd. Generally, the lists should be the same.

grep -iE "^\s*(simple_)?allow" /etc/ssh/sshd_config /etc/sssd/sssd.conf

And to run it with ansible:

ansible -i /etc/ansible/inventory -u ansible_user --become all -m shell -a 'grep -iE "^\s*(simple_)?allow" /etc/ssh/sshd_config /etc/sssd/sssd.conf'

sshd_config match negate address


Match Address *,!

Negating address in match statement in sshd_config

I was locking down my ssh server configuration on a host, so that it will not accept password auth from outside a certain IP address range.
I had to learn how to get the Match Address directive to work with a negation. To make it work, you need to insert a wildcard before you then state the exclusion.

Match Address *,!

And then I added the directives for this matched IP address range.

   AuthenticationMethods publickey
   PubkeyAuthentication yes
   PasswordAuthentication no
   X11Forwarding no




Man pages

  1. sshd_config
  2. ssh_config

sshd_config Match AD group


I use CentOS 7. One of the biggest reasons I join my servers to Active Directory is for the users and groups. Getting sshd_config to work with AD-defined groups is easy and just needs the smallest amount of work.

If you want to use sftp, and have rules for just a specific AD group, you need to specify the group name exactly as it is cased.
[root@amazon|/var/log]# getent group Web_Dev_Grp

So use the “web_dev_grp” as shown in your sshd_config:
Match Group web_dev_grp
ChrootDirectory /var/www
ForceCommand internal-sftp