Linux control remote access to SSHD

Source: Internet
Author: User

Test environment: Linux centos6.5

1. hosts.allow File configuration:

Modify the/etc/hosts.allow file
#
# Hosts.allow This file describes the names of the hosts which is
# allowed to use the local INET services, as decided
# by the '/USR/SBIN/TCPD ' server.
#
Sshd:210.13.218.*:allow
Sshd:222.77.15.*:allow
The above notation means that 210 and 2,222 IP segments are allowed to connect to the SSHD service (which must be used in conjunction with the Hosts.deny file), and of course "allow" can be omitted entirely. Of course, if the administrator is in one IP, then this is easier to write.
all:218.24.129.110//He accepts all requests for 110 of this IP!

2. hosts.deny file Configuration
/etc/hosts.deny file, this file is a list of denial of service, the file content is as follows:
#
# Hosts.deny This file describes the names of the hosts which is
# *not* allowed to use the local INET services, as decided
# by the '/USR/SBIN/TCPD ' server.
#
# The Portmap line was redundant, but it was left to remind
# The new secure Portmap uses Hosts.deny and Hosts.allow. In particular
# should know that NFS uses portmap!
Sshd:all:deny
Note: Sshd:all:deny indicates that all sshd remote connections have been rejected. :d Eny can be omitted.
So: When the Hosts.allow and Host.deny conflict, the Hosts.allow settings prevail.

Effective immediately upon completion of the modification.

3. Extension:
1. Disable SSH functionality for all IP access to Linux
You can add a row in/etc/hosts.deny Sshd:all:deny

2. Disable an IP (192.168.11.112) Access SSH feature
You can add a row in/etc/hosts.deny sshd:192.168.11.112

3. If there are sshd:192.168.11.112 rules at/etc/hosts.deny and/etc/hosts.allow, then 192.168.11.112 can access the host's SSH service


Summary: This method can control some non-authorized access, but not once and for all! When we look at the service log, we may see a lot of scan records, not or directly for the root user, then control your access list is very useful!

Linux control remote access to SSHD

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.