linux系统安全标准规范

简介:

首先确保所使用的linux系统中的所有软件都已经安装到最新版本。

linux下的漏洞或者叫做不规范大致如下几点:

用户登录,openssl, CA证书,GRUB加密,SMB密码永不过期,无任何所属用户用户组的文件,文件权限为777的,所使用到的软件严重滞后,tcp timstamp, 数据库的open access, ICMP redirection, ip forward, 

umask值的默认设置,磁盘分区的weakness

1. 使用root用户在终端登录。

sed -i '/^tty[0-9]$/d' /etc/securetty

sed -i '/^vc\/[0-9]$/d' /etc/securetty

2. 使用ssh协议的root登录

sed -i 's/#PermitRootLogin\ yes/PermitRootLogin\ no/' /etc/ssh/sshd_config

sed -i 's/#PermitRootLogin\ without-password/PermitRootLogin\ no/' /etc/ssh/sshd_config

3.  ICMP redirection 问题

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.default.accept_redirects = 0

net.ipv4.conf.all.secure_redirects = 0

net.ipv4.conf.default.secure_redirects = 0

4. 数据库的open access

使用iptables来加强数据库的访问认证。受信任的主机访问,通过设置数据库中的用户主机名称不使用%来匹配所有主机。

5. ssl使用的证书协议

不使用泛域名证书,使用至少2048bit以上的证书

The subject's common name (CN) field in the X.509 certificate should be fixed to reflect the name of the entity presenting the certificate (e.g., the hostname). This is done by generating a new certificate usually signed by a Certification Authority (CA) trusted by both the client and server.

Configure the server to require clients to use TLS version 1.2 using Authenticated Encryption with Associated Data (AEAD) capable ciphers.

There is no server-side mitigation available against the BEAST attack. The only option is to disable the affected protocols (SSLv3 and TLS 1.0). The only fully safe configuration is to use Authenticated Encryption with Associated Data (AEAD), e.g. AES-GCM, AES-CCM in TLS 1.2.

Send the HTTP response headers with X-Frame-Options that instruct the browser to restrict framing where it is not allowed.

Configure the server to disable support for 3DES suite.




6. TCP timestamp responses的问题

net.ipv4.tcp_timestamps=0

7. IP Source Routing

The host is configured to honor IP source routing options. Source routing is a feature of the IP protocol which allows the sender of a packet to specify which route the packet should take on the way to its destination (and on the way back). Source routing was originally designed to be used when a host did not have proper default routes in its routing table. However, source routing is rarely used for legitimate purposes nowadays. Attackers can abuse source routing to bypass firewalls or to map your network.

Disable IP source routing

For Linux systems ensure the following sysctl value is set:

net.ipv4.conf.all.accept_source_route=0

It is also advised that packet forwarding be disabled, unless there is a legitimate reason not to, by setting the following sysctl values:

net.ipv4.conf.all.forwarding=0

net.ipv6.conf.all.forwarding=0

net.ipv4.conf.all.mc_forwarding=0

net.ipv6.conf.all.mc_forwarding=0

More Linux information can be found at https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-Server_Security-Disable-Source-Routing.html

8. 设置grub密码

Enable GRUB password

Configuration remediation steps



Set a password in the GRUB configuration file. This is often located in one of several locations, but can really be anywhere:

         /etc/grub.conf
         /boot/grub/grub.conf
         /boot/grub/grub.cfg
         /boot/grub/menu.lst        

For all files mentioned above ensure that a password is set or that the files do not exist.

To set a plain-text password, edit your GRUB configuration file and add the following line before the first uncommented line:

  password <password>

To set an encrypted password, run grub-md5-crypt and use its output when adding the following line before the first uncommented line:

  password --md5 <encryptedpassword>

For either approach, choose an appropriately strong password.

9. 磁盘分区的挂载方式添加nodev参数

Partition Mounting Weakness

Configuration remediation steps



The specific way to modify the partition mount options varies from system to system. Consult your operating system's manual or mount man page.

The following issues were discovered: 
/boot partition does not have 'nodev' option set.
/data partition does not have 'nodev' option set.


10. 内核参数的一般优化

net.core.rmem_default = 2569600                                                    

net.core.rmem_max = 2569600                                                        

net.core.wmem_default = 2569600                                                    

net.core.wmem_max = 2569600                                                        

net.ipv4.tcp_timestamps = 0                                                        

net.ipv4.tcp_sack = 1                                                              

net.ipv4.tcp_window_scaling = 1                                                    

net.ipv4.tcp_keepalive_time = 600                                                  

kernel.sem = 500 64000 200 256                                                     

fs.file-max = 65536                                                                

net.ipv4.ip_local_port_range = 1024 65000                                          

net.ipv4.ip_forward = 0                                                            

net.ipv4.conf.default.rp_filter = 1                                                

kernel.sysrq = 0                                                                   

kernel.core_uses_pid = 1                                                           

net.ipv4.tcp_syncookies = 1                                                        

net.ipv4.tcp_max_syn_backlog = 2048                                                

net.ipv4.tcp_synack_retries = 2                                                    

net.ipv4.conf.all.accept_source_route = 0                                          

net.ipv4.conf.lo.accept_source_route = 0                                           

net.ipv4.conf.default.accept_source_route = 0                                      

net.ipv4.conf.all.rp_filter = 1                                                    

net.ipv4.conf.lo.rp_filter = 1                                                     

net.ipv4.conf.default.rp_filter = 1                                                

net.ipv4.conf.all.accept_redirects = 0                                             

net.ipv4.conf.lo.accept_redirects = 0                                              

net.ipv4.conf.default.accept_redirects = 0                                         

net.ipv4.conf.all.secure_redirects=0                                               

net.ipv4.conf.default.secure_redirects=0                                           

net.ipv4.tcp_timestamps=0


11. iptables 防攻击

-A FORWARD -p tcp --syn -m limit --limit 1de>de >/sde> de >--limit-burst 5 -j ACCEPT 限制每秒5个新连接de>

-A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1de>de >/sde> de >-j ACCEPT  防端口扫描de>

-A FORWARD -p icmp --icmp-de>de >typede> de >echode>de >-request -m limit --limit 1de>de >/sde> de >-j ACCEPT  de>防止洪水攻击















本文转自ting2junshui51CTO博客,原文链接:http://blog.51cto.com/ting2junshui/2063045 ,如需转载请自行联系原作者



相关文章
|
3天前
|
网络协议 安全 Linux
linux系统安全及应用——端口扫描
linux系统安全及应用——端口扫描
42 0
|
3天前
|
监控 安全 Linux
Linux系统的防御从多个方面来保护系统安全
防火墙:使用防火墙软件如iptables或Firewalld来限制网络流量,保护系统免受恶意网络攻击。
|
7月前
|
运维 安全 Linux
实现远程访问Linux堡垒机:通过JumpServer系统进行安全的服务器管理
实现远程访问Linux堡垒机:通过JumpServer系统进行安全的服务器管理
|
3天前
|
安全 关系型数据库 MySQL
Linux 实用小脚本系列(2)----mysql安全初始化脚本的免交互执行--mysql_secure_installation
Linux 实用小脚本系列(2)----mysql安全初始化脚本的免交互执行--mysql_secure_installation
59 0
|
3天前
|
监控 安全 Linux
【专栏】Linux SSH 的安全对于远程管理至关重要,这几个小妙招安排上!
【4月更文挑战第28天】在数字化时代,Linux SSH 的安全对于远程管理至关重要。增强 SSH 安全包括:使用强密码,调整 SSH 配置文件,尤其是端口号和认证方式;采用密钥认证代替密码;限制登录用户,禁止密码登录;使用防火墙限制访问;定期更新系统和软件。此外,通过日志监控、入侵检测系统及及时应对攻击来提升安全监控。保持对安全知识的学习和更新,结合最佳实践,是保障 SSH 安全的关键。记得安全是个持续过程,时刻保持警惕!
|
3天前
|
安全 网络协议 Linux
Linux系统管理、服务器设置、安全、云数据中心
Linux系统管理、服务器设置、安全、云数据中心
|
3天前
|
安全 Linux 网络安全
【专栏】在 Linux 中,端口连接服务和应用,过多开放的端口可能带来安全隐患,教你一招找出所有开放的端口,然后直接干掉!
【4月更文挑战第28天】在 Linux 中,端口连接服务和应用,过多开放的端口可能带来安全隐患。要找出开放端口,可使用 `netstat -anp`、`lsof -i` 或 `nmap` 命令。关闭端口可通过停止相关服务、修改防火墙规则或禁用网络接口。注意不要随意关闭重要端口,操作前备份数据。保持端口安全对系统安全至关重要。
|
3天前
|
监控 安全 Linux
【专栏】在网络安全至关重要的今天,Linux系统中的SCP和SFTP成为安全文件传输的首选工具
【4月更文挑战第28天】在网络安全至关重要的今天,Linux系统中的SCP和SFTP成为安全文件传输的首选工具。SCP,一个基于SSH的轻量级工具,允许用户方便地在本地和远程主机间复制文件。要使用SCP,首先确保安装了OpenSSH,然后通过基本命令进行文件传输,如`scp source destination`。SFTP则提供了一个类似FTP的界面,通过`sftp`命令启动客户端,进行直观的文件操作。两者均基于SSH协议,保证数据加密。为确保安全,建议使用强密码、密钥对、禁用根用户直接登录,并配置防火墙及监控日志。了解和掌握这些工具能提升工作效率并保护数据安全。
|
7月前
|
安全 Linux 网络安全
百度搜索:蓝易云 ,Linux Debian11服务器安装SSH,创建新用户并允许SSH远程登录,及SSH安全登录配置!
这些步骤提供了在Debian 11服务器上安装SSH,创建新用户并允许SSH远程登录以及进行SSH安全登录配置的指南。请确保按照步骤操作,并根据您的需求进行必要的修改。
104 0
|
3天前
|
Ubuntu 安全 Linux
Linux/Ubuntu 的日常升级和安全更新,如何操作?
Linux/Ubuntu 的日常升级和安全更新,如何操作?
89 0
Linux/Ubuntu 的日常升级和安全更新,如何操作?