centos7安全设置:用户密码/ssh安全/防火墙/系统安全等设置

admin3年前主机评测99

众所周知,Linux服务器的安全是网络运行的基础之一,只有做好了安全,我们的网站或项目才能顺利稳定运行。当然,centos7安全相关设置有很多,我们可以通过Centos系统创建用户名密码、配置ssh安全端口、设置防火墙及系统安全等环境配置。今天,小编就详细介绍一下centos7下面的一些常见安全设置吧!

centos7安全相关设置

初始化及软件安装

## 固定IP地址

## 关闭SELINUX

[root@c72 ~]# vim /etc/selinux/config

SELINUX=disabled

## 更改主机名,让hosts文件与当前主机名保持对应关系

echo bre_sch /etc/hostname

[root@c72 ~]# vim /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 bre_sch

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 bre_sch

# 关闭firewalld,后面的防火墙设置使用iptables

systemctl stop firewalld

systemctl disable firewalld

## 软件安装

cd /etc/yum.repos.d/

rm -rf ./*

curl -o /etc/yum.repos.d/CentOS-Base.repo mirrors.aliyun/repo/Centos-7.repo

yum-config-manager –add-repo http://mirrors.aliyun/docker-ce/linux/centos/docker-ce.repo

yum makecache fast

yum -y install docker-ce wget curl vim lrzsz nmap cifs-utils samba-client nfs-utils samba openssh iptables-services

yum install -y wget yum-utils device-mapper-persistent-data lvm2 net-tools

systemctl start docker

systemctl enable docker

user密码

## 创建单独的登录用户,并设置满足复杂性要求

useradd bresee ; echo 123456 | passwd –stdin bresee

ssh安全设置

## ssh连接加速,不允许反向解析

UseDNS no

## 不允许root直接登录 ,仅允许普通用户登录

PermitRootlogin no

## 更改端口为7777

Port 7777

## SSH登录连续输错五次密码,账号锁定30秒

vi /etc/pam.d/sshd

auth required pam_tally2.so deny=5 unlock_time=30

systemctl restart sshd

防火墙设置

仅开放了ssh、http和https三种服务

# 清空规划

iptables -F

# 开启80

iptables -A INPUT -p tcp –dport 80 -j ACCEPT

iptables -A INPUT -p tcp –sport 80 -j ACCEPT

# 开启443

iptables -A INPUT -p tcp –dport 443 -j ACCEPT

iptables -A INPUT -p tcp –sport 443 -j ACCEPT

## 开启ssh侦听的7777

iptables -A INPUT -p tcp –dport 7777 -j ACCEPT

iptables -A INPUT -p tcp –sport 7777 -j ACCEPT

## 开启ICMP

iptables -A INPUT -p icmp –icmp-type 8 -j ACCEPT

iptables -A INPUT -p icmp –icmp-type 0 -j ACCEPT

iptables -A OUTPUT -p icmp –icmp-type 8 -j ACCEPT

iptables -A OUTPUT -p icmp –icmp-type 0 -j ACCEPT

## 开启DNS

iptables -A INPUT -p udp –dport 53 -j ACCEPT

iptables -A INPUT -p udp –sport 53 -j ACCEPT

# 默认拒绝所有

iptables -P INPUT DROP

# 保存

service iptables save

# 开机启动

systemctl enable iptables.service

#开启服务

systemctl start iptables.service

#查看状态

systemctl status iptables.service

系统安全设置

———————————————-# 设置grub密码

## 生成密码*Ab123456

grub2-mkpasswd-pbkdf2

## 在/etc/grub.d/00_header引用密码

vim /etc/grub.d/00_header

cat <

set superusers=’root’

password_pbkdf2 root grub.p54CBD4341FC4A71B90E543581646B4E7EAE920C54A

E0F

## 重新生成

grub2-mkconfig -o /boot/grub2/grub.cfg

————————————-禁止control+alt+delete键盘重启系统

mv /usr/lib/systemd/system/ctrl-alt-del.target /tmp

————————————-history带时间参数和30秒超时设置

vim /etc/profile

# history带时间

export HISTTIMEFORMAT=”%Y-%m-%d %H:%M:%S `whoami` “

# 设置 30秒内用户无操作就字段断开终端

export TMOUT=30

服务器机箱

服务器硬件加封,防止拆机箱;

BIOS和管理口加密,防止有人重装系统;

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

CentOS系统如何禁Ping?CentOS系统设置禁Ping的常用方法

Centos系统如何禁Ping?CentOS是流行的Linux发行版之一,许多国内或国外服务器都支持该操作系统。CentOS系统默认是允许Ping的,如果您有服务器root账户管理权限,可以通过设置禁...

centos系统linux服务器快速CPU进程占用及内存资源过多的进程

Centos系统如何查看CPU进程占用及内存资源占用情况?对于linux系统操作一般使用命令居多,下面分享一下Centos快速查看占用资源最多的进程的命令,有些时候还是非常有用的,特别是在于网站访问缓...

Centos系统和宝塔Linux面板如何禁止ping设置

Centos系统和宝塔Linux面板如何禁止ping?Centos系统默认是允许ping的,如你有服务器root账户管理权限,可以通过修改Centos系统内核参数永久禁止ping。如果Centos系统...

centos系统怎么禁止Ping?Linux云服务器禁ping设置

Centos系统怎么禁止Ping?禁止ping的好处是减少扫描软件的发现几率,因为很多扫描机是先ICMP PING,然后再尝试端口。centos7 禁止ping的方式:centos7禁止ping有4种...

搬瓦工vps:Linux服务器选择CentOS、Debian、Ubuntu镜像的建议

搬瓦工vps可以安装什么系统?目前,搬瓦工VPS主机仅可以安装Linux系统,不支持直接安装Windows系统,如果我们有需要安装Windows系统话可以通过DD安装,后面我们单独的再介绍。正常安装系...

如何在Red Hat和CentOS上安装TeamViewer

如何在red hat和centos上安装teamviewer?TeamViewer可用于连接来自不同操作系统和平台(例如Windows,Android,Linux,MacOSX等)的远程系统。这使Te...