linux安全加固——服务管理

本文涉及的产品
运维安全中心(堡垒机),免费版 6个月
简介: linux安全加固——服务管理

ssh用来远程连接客户端的工具

禁止ssh空密码用户登录

 

more /etc/ssh/sshd_config


image.png


 cp -p  /etc/ssh/sshd_config /etc/ssh/sshd_config-back
  vim  /etc/ssh/sshd_config 
   systemctl restart sshd


image.png


ssh多次登录失败后锁定账号


83  more /etc/pam.d/sshd 
84  cp /etc/pam.d/sshd-back
85  cp -p /etc/pam.d/sshd /etc/pam.d/sshd-back
86  vim /etc/pam.d/sshd
auth       required     pam_tally2.so        deny=5   unlock_time=300


image.png


87  systemctl restart sshd


限制root用户远程登录

vim /etc/ssh/sshd_config
备份
cp - p  /etc/ssh/sshd_config  /etc/ssh/sshd_config-back
PermitRootLogin no       //取消注释,改为no
systemctl restart sshd


检查ssh远程使用的端口号

vim /etc/ssh/sshd_config


image.png


注释并修改端口号


image.png


systemctl restart sshd
semanage port -a -t ssh_port_t -p tcp 2233


关闭防火墙才能连接ssh


firewall-cmd —zone=public —add-port=2233/tcp  —permanent


重启ssh服务


systemctl restart sshd


设置登录超时自动注销


more /etc/profile


查看是否有

备份


cp -p  /etc/profile /etc/profile-back
vim  /etc/profile 
export TMOUT=180


image.png



相关文章
|
20天前
|
Linux
在Linux中,怎么把脚本添加到系统服务里,即用 service 来调用?
在Linux中,怎么把脚本添加到系统服务里,即用 service 来调用?
|
8天前
|
NoSQL Linux Redis
Linux Redis 服务设置开机自启动
【9月更文挑战第2天】在 Linux 系统中,可使用两种方法设置 Redis 开机自启动:一是通过创建 `redis.service` 文件并利用 systemd 进行管理,包括定义服务参数和启动脚本;二是编辑 `/etc/rc.local` 文件,在其中添加启动命令。推荐使用 systemd 方法,因为它更符合现代 Linux 系统的设计理念。设置完成后,可通过 `sudo systemctl status redis.service` 检查服务状态。
|
20天前
|
Ubuntu Linux 测试技术
在Linux中,已知 apache 服务的访问日志按天记录在服务器本地目录/app/logs 下,由于磁盘空间紧张现在要求只能保留最近7天的访问日志,请问如何解决?
在Linux中,已知 apache 服务的访问日志按天记录在服务器本地目录/app/logs 下,由于磁盘空间紧张现在要求只能保留最近7天的访问日志,请问如何解决?
|
20天前
|
监控 安全 Linux
在Linux中,如何配置VPN服务?
在Linux中,如何配置VPN服务?
|
21天前
|
Ubuntu Linux 应用服务中间件
在Linux中,如何启动、停止或重启服务?
在Linux中,如何启动、停止或重启服务?
|
22天前
|
Prometheus 监控 网络协议
在Linux中,如何监控网络服务的状态和性能?
在Linux中,如何监控网络服务的状态和性能?
|
22天前
|
域名解析 网络协议 Linux
在Linux中,如何配置DNS服务器和解析服务?
在Linux中,如何配置DNS服务器和解析服务?
|
20天前
|
机器学习/深度学习 Ubuntu Linux
在Linux中,如何按照该要求抓包:只过滤出访问http服务的,目标ip为192.168.0.111,一共抓1000个包,并且保存到1.cap文件中?
在Linux中,如何按照该要求抓包:只过滤出访问http服务的,目标ip为192.168.0.111,一共抓1000个包,并且保存到1.cap文件中?
|
20天前
|
运维 监控 网络协议
在Linux中,如何进行网络服务的监控?
在Linux中,如何进行网络服务的监控?
|
21天前
|
关系型数据库 MySQL Linux
Linux(CentOS7)搭建LAMP服务环境
本文介绍了在Linux (CentOS 7) 上搭建LAMP服务环境的详细步骤,包括安装Apache HTTPd、解决编译时依赖问题、配置Apache服务、安装PHP以及处理PHP与Apache集成时遇到的问题。同时,还涉及了防火墙设置和SELinux权限调整,确保Web服务能够正常运行。
41 2