Skip to content
Eternal Center

Eternal Center

  • Single-Node (单节点)
    • System (系统)
    • Service (服务)
    • Database (数据库)
    • Container (容器)
    • Virtualization (虚拟化)
  • Multi-Node (多节点)
    • Cluster (集群)
    • Big Data (大数据)
    • Cloud Computing (云计算)
    • Batch Processing (批量处理)
  • Approach (方式方法)
    • Languages (语言)
    • Ideas (思路)
    • Programing (编程)
    • Project (项目)
  • Eternity (永恒)
    • News (消息)
    • Creations (创作)
    • Classics (经典)
    • Legends (传说)
    • Chronicle (编年史)
    • FNIOS (宇宙公民开源学院)
Posted on May 20, 2023November 22, 2024 by Mingyu Zhu

[步骤] Linux SSH 访问的限制 (openSUSE & SLES & CentOS 7 & RHEL 7 版)

  • 正文:
    • 步骤一:启用 UseTCPWrappers 参数
    • 步骤二:设置 SSH 访问限制
      • 2.1 禁止来自所有 IP 地址的所有用户可以 SSH 本服务器
      • 2.2 只允许某些用户可以 SSH 本服务器
    • 步骤三:重启 SSH 服务
  • 参考文献:

正文:

步骤一:启用 UseTCPWrappers 参数

# vim /etc/ssh/sshd_config

将部分内容修改如下:

......
UseTCPWrappers yes
......

步骤二:设置 SSH 访问限制

2.1 禁止来自所有 IP 地址的所有用户可以 SSH 本服务器

# vim /etc/hosts.deny

添加以下内容:

......
sshd : ALL : deny

或者:

......
sshd : ALL

2.2 只允许某些用户可以 SSH 本服务器

# vim /etc/hosts.allow

添加以下内容:

......
sshd : 192.168.0.1/32: allow
sshd : 192.168.1.0/255.255.255.0: allow
sshd : zhumingyu:allow
mingyuzhu@192.168.1.1 : allow
sshd : *.eternalcenter.com EXCEPT attacker.eternalcenter.com

或者:

sshd : 192.168.0.1 : allow
sshd : 192.168.1. : allow
sshd : zhumingyu : allow
mingyuzhu@192.168.1.1 : allow
sshd : .eternalcenter.com EXCEPT attacker.eternalcenter.com

(
补充:这里以允许
1) 来自 IP 地址 192.168.0.1 的用户可以 SSH 登陆本服务器
2) 来自 IP 网段 192.168.1.0/255.255.255.0 的用户可以 SSH 登陆本服务器
3) 用户 zhumingyu 可以 SSH 登陆本服务器
4) 来自 192.168.1.1 的用户 mingyuzhu 可以 SSH 登陆本服务器
5) 来自域名 *.eternalcenter.com 除了域名 attacker.eternalcenter.com 的用户可以 SSH 登陆本服务器
为例
)

步骤三:重启 SSH 服务

# systemctl restart sshd

参考文献:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security_guide/sect-security_guide-tcp_wrappers_and_xinetd-tcp_wrappers_configuration_files

CategoriesChinese Post (中文帖子), System (系统), System Login Security (系统登录安全), System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志), System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件), System Security (系统安全), System Setting (系统设置), System Setting Other Steps (系统设置其它步骤), System Setting Others (系统设置其它)

Post navigation

Previous PostPrevious [排错] Linux 解决启动时,某个盘挂不上或者报错 “Warning: dracut-initqueue timeout – starting timeout scripts”
Next PostNext [步骤] Linux SSH 访问的限制 (Rocky Linux 8 & RHEL 8 版)

Aspiration (愿景):

Everyone can achieve self-achievement and self-happiness fairly

每个人都能公平地实现自我成就和自我幸福

Logo (徽标):

Additional Information (其他信息):

About     Manual     Clone     Contact
Disclaimer     Friendly Links     Donation

关于     手册     克隆     联系
免责声明     友情链接     捐赠

Search Inside Website (站内搜索)

Search Outside Website (站外搜索):

Google         Wikipedia         Bing

Eternal URL (永恒网址):

https://eternity.eternalcenter.com Will be last access method / 将是最后的访问方式

Proudly powered by LNMP Proudly powered by WordPress