How to block ssh via /etc/hosts.deny

Hi..,

I am using redhat5 server, i want to know the details about to block ssh via /etc/hosts.deny. Need help immediately

You have to use TCP wrappers. Assuming you are on RHEL5, sshd comes precompiled with TCP wrappers. You can use ldd to check if your particular sshd has TCP wrapper support, e.g.

# ldd /usr/sbin/sshd | grep libwrap
        libwrap.so.0 => /lib64/libwrap.so.0 (0x00002b14120a7000)

Note that access rules in /etc/hosts.allow are applied first i.e. they take precedence over rules specified in /etc/hosts.deny. Therefore, if access to a service is allowed in /etc/hosts.allow, a rule denying access to in /etc/hosts.deny is ignored because libwrap implements a "stop on first match" policy.