Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Is there any way to restrict ssh login from specific linux group to specific host?

I want to reach something like "AllowUsers user1@host" for linux groups.

Like: "AllowGroups group@host", but that didn't work.

That is useful because one group can login from all hosts (@host isn't specified), second group only from localhost (for web-based ssh client which forces limited shell)

I read a lot of material from internet, but I wonder that I didn't find anything to cover this problem.

share|improve this question

migrated from Oct 30 '11 at 10:36

This question came from our site for professional and enthusiast programmers.

Read about the Match keyword in sshd_config. – Alex Holst Oct 30 '11 at 11:32
up vote 1 down vote accepted

You can do this with pam_access module, something like this:

+ : (group1) : ALL
+ : (group2) :
- : ALL : ALL

Activate this module by adding the following line into /etc/pam.d/sshd:

account     required

Also make sure that you've enabled PAM in /etc/ssh/sshd_config:

UsePAM yes
share|improve this answer

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.