Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SSH to restrict IP login in CentOS

2025-04-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of how to use SSH to restrict IP login in CentOS, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this CentOS article on how to use SSH to restrict IP login. Let's take a look.

Demonstration environment

192.168.1.81:CentOS 6

192.168.0.222:Win 10

192.168.1.135:Win 8.1

Both 192.168.0.222 and 192.168.1.135 can log in to 192.168.1.81 without any settings. 192.168.0.222

192.168.1.135

Example 1: only 192.168.0.222 is allowed to login to 192.168.1.81

# vim / etc/hosts.allow add the last line: sshd:192.168.0.222:allow / / multiple IP can write multiple lines according to this format # vim / etc/hosts.deny join the last line: sshd:ALL / / except for the IP allowed to log in above, all IP refuse to log in # service sshd restart192.168.0.222 can log in normally

192.168.1.135 failed to log in normally

Example 2: only hosts on the 192.168.1 network segment are allowed to log in to 192.168.1.81

# add sshd:192.168.1.*:allow to the last line of vim / etc/hosts.allow

# the last line of vim / etc/hosts.deny adds: sshd:ALL

# service sshd restart192.168.0.222 cannot log in normally

192.168.1.135 can log in normally

Example 3: only 192.168.0.222 is allowed to log in as keyso and 192.168.1.135 as root

# the last line of vim / etc/ssh/sshd_config adds AllowUsers keyso@192.168.0.222 root@192.168.1.135 / / multiple usernames @ IP separated by spaces

# service sshd restart192.168.0.222 cannot log in normally as the default root user

192.168.0.222 can log in normally as keyso user

192.168.1.135 can log in normally as the default root user

This is the end of the article on "how to use SSH to restrict IP login in CentOS". Thank you for reading! I believe that everyone has a certain understanding of "how to use SSH to restrict IP login in CentOS". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report