Restrict SSH access to the source and prohibit access to addresses that are outside of 4A

Source: Internet
Author: User
Tags ssh access

"Fuel Node"

In the/etc/hosts.allow file
Add to:
Sshd:10.129.0.1:allow
Sshd:10.129.0.2:allow
Sshd:10.129.0.3:allow
Sshd:10.129.3.1:allow
Sshd:10.129.3.2:allow
Sshd:10.129.3.3:allow

In the/etc/hosts.deny file
Add to:
Sshd:all

Last sshd restart
Service sshd Restart

"Control Node"

In the/etc/hosts.allow file
Add to:
Sshd:10.129.0.1:allow
Sshd:10.129.0.2:allow
Sshd:10.129.0.3:allow
Sshd:10.129.3.1:allow
Sshd:10.129.3.2:allow
Sshd:10.129.3.3:allow
Sshd:10.254.1.1:allow

In the/etc/hosts.deny file
Add to:
Sshd:all

Last sshd restart
Service sshd Restart

"Compute Node"

In the/etc/hosts.allow file
Add to:
Sshd:10.129.0.1:allow
Sshd:10.129.0.2:allow
Sshd:10.129.0.3:allow
Sshd:10.129.3.1:allow
Sshd:10.129.3.2:allow
Sshd:10.129.3.3:allow
Sshd:10.254.1.1:allow
Sshd:10.254.1.15:allow
Sshd:10.254.1.30:allow
Sshd:10.254.1.45:allow

In the/etc/hosts.deny file
Add to:
Sshd:all

Last sshd restart
Service sshd Restart

Where the compute node can use the following script:

#! /bin/bash
Line= ' grep ^10 ~/hosts|wc-l '
For i in ' seq $line '
Do
Des= ' grep ^10 hosts|sed-n ${i}p '
SSH $des ' echo ' sshd:10.129.0.1:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.129.0.2:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.129.0.3:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.129.3.1:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.129.3.2:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.129.3.3:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.254.1.1:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.254.1.15:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.254.1.30:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:10.254.1.45:allow ' >>/etc/hosts.allow '
SSH $des ' echo ' sshd:all ' >>/etc/hosts.deny '
SSH $des ' service sshd restart '

echo $des >> Ip.log
Done
if [$i = = $line];then
Echo ' Deploy success '
Else
Echo ' Deploy failed '
Fi

Restrict SSH access to the source and prohibit access to addresses that are outside of 4A

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.