Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

CentOS 配置 SSH 存取控制:hosts.allow/deny 設定與服務重啟驗證

編輯:Linux 教學

在 VMware 安裝 CentOS Server 後,終端機無法捲動,需透過 Windows 的 Xshell 遠程管理。預設已安裝 SSH,僅需配置 TCP Wrappers 存取控制。

步驟

  1. 拒絕所有預設連線:編輯 /etc/hosts.deny,尾行新增 sshd:ALL。
  2. 允許內網網段:編輯 /etc/hosts.allow,尾行新增 sshd:192.168.0. (允許 192.168.0.1-254)。
  3. 重啟 SSH 服務生效:/etc/rc.d/init.d/sshd restart (或 systemctl restart sshd)。

驗證:內網主機可連線,外部 IP 被拒絕。注意:hosts.allow 優先於 hosts.deny,規則由上而下第一匹配生效。

Copyright © Windows教程網 All Rights Reserved