Tuesday 17 November 2009

Restrict ssh access to Linux server to members of a group

You may want to restrict ssh access to a server to members of a group. I faced this problem when I only wanted members in the "consultants" group to be able to log into our CentOS server.

In order to achieve this, you need only edit the file sshd_config (in CentOS, it is located in /etc/ssh, but this may be distribution-dependent) and add the following line to it:

AllowGroups consultants

Mind that this line, contrary to intuition, does not grant members of the "consultants" group the right to log in, but restricts this right to any other member in any other group. So, perhaps you may want to use

AllowGroups consultants root

instead so as to allow root logins (just in case).

No comments:

Post a Comment