For a TCP Wrappers-aware sshd, allow connections from 192.0.2.0/24 in /etc/hosts.allow.
Handle other sources with separate rules.
Which line is appropriate?
The basic hosts.allow and hosts.deny syntax is DAEMON_LIST : CLIENT_LIST, so sshd : 192.0.2.0/24 allows that network.
Detailed explanation
192.0.2.0/24 : sshdIncorrect. The daemon and client lists are reversed.
Incorrect. The daemon and client lists are reversed.
sshd = allow 192.0.2.0/24Incorrect. It is not the hosts.allow daemon:client syntax.
Incorrect. It is not the hosts.allow daemon:client syntax.
ALLOW sshd FROM 192.0.2.0/24Incorrect. This is SQL-like syntax, not a TCP Wrappers rule.
Incorrect. This is SQL-like syntax, not a TCP Wrappers rule.
sshd : 192.0.2.0/24Correct. It specifies sshd and the permitted client network.
Correct. It specifies sshd and the permitted client network.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'sshd : 192.0.2.0/24' | cut -d: -f1Expected result
sshd Key points
- Daemon on the left
- Client on the right
- Separate with a colon
Notes
- Environment: hosts_access rule構文の表示のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.