2008-05-06-how-to-limit-ssh-access-to-specific-users-or-groups.md 1.05 KB
Newer Older
Danesh Manoharan's avatar
Danesh Manoharan committed
1
2
---
title: How to limit ssh access to specific users or groups
3
author: Danesh Manoharan
Danesh Manoharan's avatar
Danesh Manoharan committed
4
5
6
7
8
9
10
11
12
date: 2008-05-06T02:00:23+00:00
pvc_views:
  - 17846
dsq_thread_id:
  - 889978590

---
Its sometimes necessary to limit who has access to a server via SSH. Most Linux security hardening checklist today require this to be enforced.

13
Fortunately this can be easily done with openSSH. Just edit the /etc/ssh/sshd_config file and add the desired directives shown below. You don't need them all, just use what suits you needs.
Danesh Manoharan's avatar
Danesh Manoharan committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27

openSSH provides 4 directives, AllowUsers, AllowGroups, DenyUsers and DenyGroups

`AllowUsers buddy john doe`  
Only users _buddy_, _john_ and _doe_ will be able to log in via ssh.

`AllowGroups sysadmin bkpadmin`  
Only users within groups _sysadmin_ and _bkpadmin_ will be able to log in via ssh.

`DenyUsers rambo tina`  
This is the opposite of AllowUsers. All users except for _rambo_ and _tina_ will be able to log in via ssh.

`DenyGroups hr payroll`  
This is the opposite of AllowGroups. All groups except for _hr_ and _payroll_ will be able to log in via ssh.