![특정 서브넷의 특정 사용자에게 SSH를 제한하는 방법](https://linux55.com/image/218426/%ED%8A%B9%EC%A0%95%20%EC%84%9C%EB%B8%8C%EB%84%B7%EC%9D%98%20%ED%8A%B9%EC%A0%95%20%EC%82%AC%EC%9A%A9%EC%9E%90%EC%97%90%EA%B2%8C%20SSH%EB%A5%BC%20%EC%A0%9C%ED%95%9C%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
SSH를 특정 서브넷의 특정 사용자로 제한하는 옵션이 있습니까? 예:[이메일 보호됨]/24를 비활성화해야 합니다.
답변1
응, 그렇지설명서에:
AllowUsers
This keyword can be followed by a list of user name
patterns, separated by spaces. If specified, login is
allowed only for user names that match one of the patterns.
Only user names are valid; a numerical user ID is not
recognized. By default, login is allowed for all users.
If the pattern takes the form USER@HOST then USER and HOST
are separately checked, restricting logins to particular
users from particular hosts. HOST criteria may
additionally contain addresses to match in CIDR
address/masklen format. The allow/deny users directives
are processed in the following order: DenyUsers,
AllowUsers.
....하지만 저는 개인적으로 이것을 사용하지 않을 것입니다. 끊임없이 변화하는 사용자 목록을 유지하는 것은 PITA가 될 것입니다. IMHO 더 나은 접근 방식은 사용자 그룹과 일치 블록을 사용하는 것입니다.
Match 192.168.0.10/24
AllowGroups PrivateSubnetSshUsers
Match 0.0.0.0/0
AllowGroups SshUsers
그런데 SSH를 통해 루트 계정에 직접 액세스를 허용하는 것은 일반적으로 안티 패턴으로 간주됩니다. Openssh에는 이러한 일이 발생하지 않도록 하는 특정 구성 옵션도 있습니다.
(고려할 수 있는 다른 사항은 일치하는 블록과 함께 "AllowGroups root / AllowGroups !root" 또는 "PermitRootLogin yes / PermitRootLogin no"입니다.)