安全加固方案

交换机安全加固

查看是否关闭未使用的接口

|------------------------------------------|
| 25GE1/0/1、25GE1/0/47、25GE1/0/48需要使用,暂不关闭 |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| system-view # interface Eth-Trunk99 shutdown quit interface Eth-Trunk100 shutdown quit interface Eth-Trunk110 shutdown quit interface 25GE1/0/2 shutdown interface 25GE1/0/3 shutdown interface 25GE1/0/4 shutdown interface 25GE1/0/5 shutdown interface 25GE1/0/6 shutdown interface 25GE1/0/7 shutdown interface 25GE1/0/8 shutdown interface 25GE1/0/9 shutdown interface 25GE1/0/10 shutdown interface 25GE1/0/11 shutdown interface 25GE1/0/12 shutdown interface 25GE1/0/13 shutdown interface 25GE1/0/14 shutdown interface 25GE1/0/15 shutdown interface 25GE1/0/16 shutdown interface 25GE1/0/17 shutdown interface 25GE1/0/18 shutdown interface 25GE1/0/19 shutdown interface 25GE1/0/20 shutdown interface 25GE1/0/21 shutdown interface 25GE1/0/22 shutdown interface 25GE1/0/23 shutdown interface 25GE1/0/24 shutdown interface 25GE1/0/25 shutdown interface 25GE1/0/26 shutdown interface 25GE1/0/27 shutdown interface 25GE1/0/28 shutdown interface 25GE1/0/29 shutdown interface 25GE1/0/30 shutdown interface 25GE1/0/31 shutdown interface 25GE1/0/32 shutdown interface 25GE1/0/33 shutdown interface 25GE1/0/34 shutdown interface 25GE1/0/35 shutdown interface 25GE1/0/36 shutdown interface 25GE1/0/37 shutdown interface 25GE1/0/38 shutdown interface 25GE1/0/39 shutdown interface 25GE1/0/40 shutdown interface 25GE1/0/41 shutdown interface 25GE1/0/42 shutdown interface 25GE1/0/43 shutdown interface 25GE1/0/44 shutdown interface 25GE1/0/45 shutdown interface 25GE1/0/46 shutdown interface 100GE1/0/1 shutdown interface 100GE1/0/2 shutdown interface 100GE1/0/3 shutdown interface 100GE1/0/4 shutdown interface 100GE1/0/5 shutdown interface 100GE1/0/6 shutdown interface 100GE1/0/7 shutdown interface 100GE1/0/8 shutdown quit # commit quit save Y |

检查是否配置远程访问****IP 地址限制

|-----------------------------------|
| ssh 放行全部地址进来,后面需要网管老师去限定ssh的入向源地址 |

|-----------------------------------------------------------------------------------------------------------------------------------|
| system-view # acl number 2000 rule 200 permit source any quit # user-interface vty 0 4 acl 2000 inbound quit # commit quit save Y |

检查是否配置防地址欺骗攻击

|---------------------|
| 目前使用端口都为2层口,暂不支持该功能 |

Ubunut20.04****安全加固

|-----------------------------------|
| 需使用root账号配置 cmcc登录后使用su - root 切换 |

设置重复登录失败后锁定时间限制、查口令锁定策略

**内容:**设置密码输入错误5次后锁定账户15分钟(900秒)、帐户被锁定,不再提示让再次登录;

vim /etc/pam.d/common-auth

在图中位置添加如下命令

auth required pam_tally2.so deny=5 onerr=fail no_magic_root unlock_time=900

验证

解锁账户

设置用户缺省****UMASK 、登录超时

**内容:**设置umask 027、登陆超时30分钟

步骤:

vim /etc/profile

在末尾添加

|----------------------------------------------|
| Plain Text umask 027 TMOUT=1800 export TMOUT |

保存退出

生效配置

root@cmcc:~# source /etc/profile

验证

设置限制****su 命令用户组

内容:添加 wheel 组并将 cmcc 添加到改组,启用 su 命令控制

步骤:

vim /etc/pam.d/su

在打开的配置文件的中,添加以下参数:
auth required pam_wheel.so

保存退出

创建 wheel 并添加用户

|--------------------------------------------|
| Shell groupadd wheel usermod -G wheel cmcc |

验证

cmcc添加到wheel组后可以切换root

非wheel组用户无法切换

设置****SSH 是否使用业界认可的加密算法

内容: ssh 添加指定算法

步骤:

使用文本编辑器(如vim)编辑/etc/ssh/sshd_config文件。
vi /etc/ssh/sshd_config

在打开的配置文件中,如图位置添加如下参数:

Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr

KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256

MACs umac-128-etm@openssh.com,umac-64-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256

保存并退出

在vim编辑器中,按Esc键,然后输入:wq并回车以保存更改并退出编辑器。

生效配置

root@cmcc:/etc/ssh# sshd -T #检查配置有无问题

Missing privilege separation directory: /run/sshd

root@cmcc:/etc/ssh# systemctl restart sshd

root@cmcc:/etc/ssh# systemctl status sshd

限制****root 远程登陆

内容: root 远程登录不成功

步骤:

|----------------------------------------------------------|
| Shell vi /etc/ssh/sshd_config #添加如下内容 PermitRootLogin no |

修改PermitRootLogin设置为no并不被注释,保存退出。

生效配置

|--------------------------------------------------------------------------------------------|
| Shell root@cmcc:/etc/ssh# systemctl restart sshd root@cmcc:/etc/ssh# systemctl status sshd |

验证

尝试使用ssh登录root,回显不通过。

检查登录提示**-** 是否设置 ssh 警告

内容: ssh 登录时 提示 Authorized users only. All activity may be monitored and reported

步骤:

echo " Authorized users only. All activity may be monitored and reported " >/etc/sshbanner

vim /etc/ssh/sshd_config文件

在打开的配置文件的中,添加以下参数并保存退出:

|-----------------------------|
| Shell Banner /etc/sshbanner |

重启服务

systemctl restart sshd

验证

检查系统是否不存开发编译及网络嗅探类工具

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Shell #查看安装的软件包 root@cmcc:~# apt list --installed Tcpdump Listing... Done root@cmcc:~# apt list --installed Gdb Listing... Done root@cmcc:~# apt list --installed strace Listing... Done strace/focal,now 4.26-0.2ubuntu3 amd64 [installed,upgradable to: 5.5-3ubuntu1] root@cmcc:~# apt list --installed dexdump Listing... Done root@cmcc:~# apt list --installed cpp Listing... Done root@cmcc:~# apt list --installed gcc Listing... Done root@cmcc:~# apt list --installed tcpdump Listing... Done root@cmcc:~# apt list --installed ethereal Listing... Done root@cmcc:~# apt list --installed wireshark Listing... Done #卸载安装的软件包 root@cmcc:~# apt autoremove strace Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: libunwind8 strace ubuntu-standard 0 upgraded, 0 newly installed, 3 to remove and 310 not upgraded. After this operation, 1,798 kB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 70747 files and directories currently installed.) Removing ubuntu-standard (1.450) ... Removing strace (4.26-0.2ubuntu3) ... Removing libunwind8:amd64 (1.2.1-9build1) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9) ... |

检查是否关闭****IP 转发功能、是否开启反向路径过滤、禁止 icmp 重定向

|--------------|
| 系统默认没开IP转发功能 |

|----------------------------------------------------------------------------------------------------------|
| Shell sysctl net.ipv4.ip_forward sysctl net.ipv4.conf.all.forwarding sysctl net.ipv4.conf.all.forwarding |

如果要修改

vim /etc/sysctl.conf文件

并在/etc/sysctl.conf中添加如下内容:

|----------------------------------------------------------------------------------------------------|
| Bash net.ipv4.ip_forward = 0 net.ipv4.conf.all.forwarding = 0 net.ipv4.conf.default.forwarding = 0 |

修改后,运行sysctl -p来应用更改。

|--------------------|
| 配置文件仲该设置被注释了取消注释即可 |

vim /etc/sysctl.conf 把 # 去掉 然后保存退出

生效配置

日志大小进行配置

内容:修改日志大小位 10M

步骤:

Vim /etc/logrotate.d/rsyslog

在打开的配置文件的中,添加以下参数并保存退出:

size 10M

重启服务

systemctl restart rsyslog.service

检查帐号文件权限设置

内容:修改文件权限

步骤:

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Shell root@cmcc:~# ls -la /etc/passwd -rw-r--r-- 1 root root 2016 Oct 31 05:52 /etc/passwd # 文件权限 644 root@cmcc:~# ls -la /etc/group -rw-r--r-- 1 root root 861 Nov 4 02:28 /etc/group # 文件权限 644 root@cmcc:~# ls -la /etc/shadow -rw-r----- 1 root shadow 1928 Oct 31 05:52 /etc/shadow # 文件权限 400 不符合要求 |

返回如下

|------------------------------------------------------------------------|
| Shell chmod 400 /etc/shadow chmod 644 /etc/group chmod 644 /etc/shadow |

开启命令及登录失败记录

内容:开启登录失败记录

步骤:

vim /etc/login.defs

找到 LASTLOG_ENAB 项 ,取消注释 并添加yes

找到 FAILLOG_ENAB 取消注释 并添加yes (如果已经修改则无需变动)

保存文件并退出 wq

口令重复次数限制、口令生存周期要求

内容:强制密码历史 " 设置为 " 记住 5 个密码;口令生存周期最大 90 天,最小 8 天,不足 7 天告警

口令重复次数限制

创建文件/etc/security/opasswd,并设置权限: #

touch /etc/security/opasswd

chown root:root /etc/security/opasswd

chmod 600 /etc/security/opasswd 3、修改策略设置: #vi /etc/pam.d/common-passwd 在password required pam_unix.so所在行增加remember=5,保存退出。

口令生存周期要求

  • 编辑/etc/login.defs文件,设置密码的过期策略,保存退出:

|--------------------------------------------------------|
| Shell PASS_MAX_DAYS 90 PASS_MIN_DAYS 7 PASS_WARN_AGE 7 |

修改cmcc用户密码生成周期

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Shell root@cmcc:~# chage -M 90 -m 8 -W 7 cmcc root@cmcc:~# chage -l cmcc Last password change : Nov 04, 2024 Password expires : Feb 02, 2025 Password inactive : never Account expires : never Minimum number of days between password change : 7 Maximum number of days between password change : 90 Number of days of warning before password expires : 7 root@cmcc:~# |

配置****ntp 时间同步

使用Mobaxterm 上传ntp离线包

dpkg -i ntp_4.2.8p10+dfsg-5ubuntu7_arm64.deb

systemctl restart ntp

systemctl status ntp

漏扫工具的使用

离线检查操作使用说明

一、概述:

所有离线检查,均可通过Secure CRT执行vbs脚本进行,检查脚本执行完毕后,自动生成签名加密的result结果文件,将生成的result结果文件导入离线新建计划生成扫描报告。请勿私自打开修改result结果文件内容,否则将无法生成结果报告并计算合规率。

二、注意事项:

在进行离线检查前,请仔细阅读以下注意事项:

1、务必使用Version 8.1.0版本及以上的SecureCRT进行离线合规检查。

2、务必将SecureCRT设置成仿真Linux环境,具体设置方法如下:

通过SecureCRT(Version 6.5.0以上)登录设备,设置SecureCRT仿真终端为"Linux",设置过程为:"选项"->"会话选项"->"终端"->"仿真",选择"Linux",如果已经连接远程设备,需要重新连接,更改的设置才会生效

3、务必使用最高权限用户执行离线检查脚本,用SecureCRT登录后,先设置仿真终端为Linux,然后切换到最高权限用户,(主机系统为root,网络设备为super或enable用户),保证有足够权限执行脚本;

4、务必取消SecureCRT记录会话日志选项,即取消记录"会话日志"和"会话原始日志"。"文件"---"会话日志"、"文件"---"会话原始日志"。

5、对于语系为中文的操作系统,建议将CRT默认字符编码修改为UTF-8,即"选项"---"会话选项"---"终端"---"外观",右边"字符编码"修改为"UTF-8"。

在实际执行过程中发现个别设备的结果文件里报 ' 无效的过程调用或参数 ' 错误,可以切换字符编码为 default gb2312 再重新执行脚本,看是否正常返回结果。

6、离线检查过程中,同时只能打开一个SecureCRT标签即每次只检查一台设备,为加快效率,可以启动SecureCRT打开多个CRT窗口同时进行多个设备检查。

7、如果离线检查脚本执行过程中,弹出以下窗口

点击"运行",即可继续执行离线合规检查。

8、Windows支持本机直接运行bat脚本方式,将脚本文件分别上传到待检查Windows主机上,选择bat文件夹下面的start.bat进行检查,建议使用该方法检查。若以SecureCRT方式执行.vbs检查,需要本机开启telnet服务。

9、 Oracle数据库在检查执行过程中,需要切换到Oracle安装用户和输入oracle数据库安装路径(listener.ora和sqlnet.ora文件路径,输入到/network/admin前面截止即可),才可以继续往下执行。弹出相应对话框,按照要求输入后,点击确定即可。

10、Sybase数据库在检查执行过程中,需要登陆数据库,才可以继续往下执行。这时会弹出Logon窗口,分别输入用户名及密码,进行登陆。其他类型数据库,根据提示,输入相应数据即可,就不逐一举例。

11、Informix数据库离线合规检查,主要检查其依赖主机的合规性配置。同时,如果数据库默认配置文件onconfig、adtcfg已经重命名,请电联河北公司要求提供定制性脚本。

12、中间件设备类型在离线合规检查过程中,会弹出Path对话框,提示输入中间件安装路径,输入后,点击"确定"按钮,继续执行。中间件所在的各种操作系统下,输入的路径都由根目录开始,到中间件目录为止,最后不需要分隔符。如:

Windows:c:\midware\tomcat-6.0.35

Linux: /opt/apache-6.0.35

三、离线检查示例:

https://tdsmartcloud.feishu.cn/drive/folder/FeNYfkuORlPXlDdcFUAcEcoMnzb

使用CRT SSH连接机器后

选择vbs文件

运行过程需要输入机器

扫描完成

扫描后会在生成一个result目录

将扫描结果发送给客户

相关推荐
渣哥9 小时前
原来 Java 里线程安全集合有这么多种
java
间彧9 小时前
Spring Boot集成Spring Security完整指南
java
间彧9 小时前
Spring Secutiy基本原理及工作流程
java
Java水解10 小时前
JAVA经典面试题附答案(持续更新版)
java·后端·面试
洛小豆12 小时前
在Java中,Integer.parseInt和Integer.valueOf有什么区别
java·后端·面试
前端小张同学13 小时前
服务器上如何搭建jenkins 服务CI/CD😎😎
java·后端
ytadpole13 小时前
Spring Cloud Gateway:一次不规范 URL 引发的路由转发404问题排查
java·后端
华仔啊13 小时前
基于 RuoYi-Vue 轻松实现单用户登录功能,亲测有效
java·vue.js·后端
程序员鱼皮14 小时前
刚刚 Java 25 炸裂发布!让 Java 再次伟大
java·javascript·计算机·程序员·编程·开发·代码