
SSHを特定のサブネットの特定のユーザーに制限するオプションはありますか?例:[Eメール保護]/ 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経由でrootアカウントへの直接アクセスを許可するのは通常、アンチパターンと見なされます。 Opensshには、これが発生しないようにする特定の設定オプションもあります。
(考えることができる他のものは、一致するブロックと共に「AllowGroups root / AllowGroups !root」または「PermitRootLogin yes / PermitRootLogin no」です。)