当前位置:   article > 正文

Linux安全加固--精简启动项

lvm2-monitor

1、关闭不必要的服务

1.1、centos6.x服务操作命令

1.1.1、常用命令

查看服务开启或关闭状态:

  1. [root@localhost ~]# chkconfig --list
  2. aegis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  3. agentwatch 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  4. atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  5. auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  6. blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off
  7. cloud-config 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  8. cloud-final 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  9. cloud-init 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  10. cloud-init-local 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  11. cloud-init-upgrade 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  12. cloudmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  13. crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  14. ecs_mq-service 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  15. eni-service 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  16. htcacheclean 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  17. httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  18. ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  19. iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  20. irqbalance 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  21. iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  22. iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  23. lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off
  24. mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  25. multipathd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  26. mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  27. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  28. netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  29. network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  30. nscd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  31. ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  32. ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  33. php-fpm 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  34. postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  35. rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  36. restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  37. rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  38. saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  39. sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  40. svnserve 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  41. sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
  42. udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
  43. xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
  44. xinetd based services:
  45. chargen-dgram: off
  46. chargen-stream: off
  47. daytime-dgram: off
  48. daytime-stream: off
  49. discard-dgram: off
  50. discard-stream: off
  51. echo-dgram: off
  52. echo-stream: off
  53. rsync: off
  54. tcpmux-server: off
  55. time-dgram: off
  56. time-stream: off
  57. [root@localhost ~]#

单独查看某一个服务的状态:

  1. [root@localhost ~]# chkconfig postfix --list
  2. postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  3. [root@localhost ~]#

让某个服务开机不启动:

  1. [root@localhost ~]# chkconfig postfix off
  2. [root@localhost ~]# chkconfig postfix --list
  3. postfix 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  4. [root@localhost ~]#

让某个服务在指定init级别启动:

  1. [root@localhost ~]# chkconfig postfix --level 234 on
  2. [root@localhost ~]# chkconfig postfix --list
  3. postfix 0:off 1:off 2:on 3:on 4:on 5:off 6:off
  4. [root@localhost ~]#

让某个服务在指定init级别关闭:

  1. [root@localhost ~]# chkconfig postfix --level 234 off
  2. [root@localhost ~]# chkconfig postfix --list
  3. postfix 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  4. [root@localhost ~]#

让某个服务在所有级别(默认2345)都启动:

  1. [root@localhost ~]# chkconfig postfix on
  2. [root@localhost ~]# chkconfig postfix --list
  3. postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  4. [root@localhost ~]#

查看系统服务的相关说明:

  1. [root@localhost ~]# rpm -qi $(rpm -qf /etc/init.d/postfix)
  2. Name : postfix Relocations: (not relocatable)
  3. Version : 2.6.6 Vendor: CentOS
  4. Release : 6.el6_7.1 Build Date: Tue 10 Nov 2015 05:59:54 PM HKT
  5. Install Date: Wed 22 Aug 2018 11:38:05 AM HKT Build Host: c6b8.bsys.dev.centos.org
  6. Group : System Environment/Daemons Source RPM: postfix-2.6.6-6.el6_7.1.src.rpm
  7. Size : 10190116 License: IBM
  8. Signature : RSA/SHA1, Tue 10 Nov 2015 08:41:47 PM HKT, Key ID 0946fca2c105b9de
  9. Packager : CentOS BuildSystem http://bugs.centos.org
  10. URL : http://www.postfix.org
  11. Summary : Postfix Mail Transport Agent
  12. Description :
  13. Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL),
  14. TLS
  15. [root@localhost ~]#

以上命令只适用于系统自带的服务,或者用yum和rpm安装的一些服务,如果是自己源码安装的,可能没这么详细。

自己安装了一些服务之后,可以手动将它们加进系统服务管理中:

如何增加一个服务:

1、服务脚本必须存放在/etc/ini.d/目录下;

2、chkconfig --add servicename

在chkconfig工具服务列表中增加此服务,此时服务会被在/etc/rc.d/rcN.d中赋予K/S入口了;

3.chkconfig --level35 mysqld on

修改服务的默认启动等级。

1.1.2、关闭不需要的服务

这里,postfix服务是提供邮件服务的,这里我们并没有用到,所以我们选择把它关闭

  1. [root@localhost ~]# chkconfig postfix off
  2. [root@localhost ~]# chkconfig postfix --list
  3. postfix 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  4. [root@localhost ~]#

服务可能在运行,我们让服务现在就关闭:

  1. [root@localhost ~]# service postfix stop
  2. Shutting down postfix: [ OK ]
  3. [root@localhost ~]# service postfix status
  4. master is stopped
  5. [root@localhost ~]#

其它服务也一样操作,下面我们会列出一个可以关闭的服务列表。

1.2、Centos7.x服务操作命令

1.2.1、常用命令

查看服务开启或关闭状态:

CentOS7已不再使用chkconfig 管理启动项,使用systemctl工具来管理服务程序,包括了service和chkconfig

启动一个服务: systemctl start firewalld.service

关闭一个服务: systemctl stop firewalld.service

重启一个服务: systemctl restart firewalld.service

显示一个服务的状态: systemctl status firewalld.service

在开机时启用一个服务: systemctl enable firewalld.service

在开机时禁用一个服务: systemctl disable firewalld.service

查看服务是否开机启动: systemctl is-enabled firewalld.service;echo $?

查看已启动的服务列表: systemctl list-unit-files|grep enabled

使用 systemctl list-unit-files 可以查看各个服务的状态,这个信息有点多,

image

所以我们过滤一下打开的:

  1. [root@localhost ~]# systemctl list-unit-files | grep enable
  2. auditd.service enabled
  3. autovt@.service enabled
  4. crond.service enabled
  5. dbus-org.fedoraproject.FirewallD1.service enabled
  6. firewalld.service enabled
  7. getty@.service enabled
  8. irqbalance.service enabled
  9. kdump.service enabled
  10. lvm2-monitor.service enabled
  11. microcode.service enabled
  12. NetworkManager-wait-online.service enabled
  13. postfix.service enabled
  14. rsyslog.service enabled
  15. sshd.service enabled
  16. systemd-readahead-collect.service enabled
  17. systemd-readahead-drop.service enabled
  18. systemd-readahead-replay.service enabled
  19. tuned.service enabled
  20. vmtoolsd.service enabled
  21. xinetd.service enabled
  22. dm-event.socket enabled
  23. lvm2-lvmetad.socket enabled
  24. lvm2-lvmpolld.socket enabled
  25. default.target enabled
  26. multi-user.target enabled
  27. remote-fs.target enabled
  28. runlevel2.target enabled
  29. runlevel3.target enabled
  30. runlevel4.target enabled
  31. [root@localhost ~]#

1.2.2、关闭不需要的服务

同上面一样,接下来我们关闭postfix服务。

  1. [root@localhost ~]# systemctl disable postfix.service
  2. Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.
  3. [root@localhost ~]#
  4. [root@localhost ~]# systemctl list-unit-files | grep postfix
  5. postfix.service disabled

关闭正在运行的postfix

[root@localhost ~]# systemctl stop postfix.service

1.3、系统启动项列表

参考:https://blog.csdn.net/alexdream/article/details/10955797

https://www.cnblogs.com/jonsea/p/5571267.html

https://www.getlinux.cn/centos7-x-chang-yong-fu-wu-jian-jie.html

服务名称

功能

默认

建议

备注

aegis

阿里云安骑士

on

on

agentwatch

阿里云Ecs监控

on

on

atd

计划任务,/etc/at.allow,/etc/at.deny

on

off

可用crond代替

auditd

配合selinux审核

on

off

autovt

登录相关

on

on

blk-availability

lvm2相关

on

on

有lvm就开

cloud-config

Ecs云配置,配合cloud-init

on

on

cloud-final

配合cloud-init

on

on

cloud-init

云初始化服务

on

on

cloud-init-local

配合cloud-init

on

on

cloud-init-upgrade

配合cloud-init

on

on

cloudmonitor

云监控

on

on

crond

计划任务

on

on

dbus-org.fedoraproject.FirewallD1

桌面网卡管理

on

off

default.target

默认启动项

on

on

multi-user.target

同default.target

on

on

ecs_mq-service

Ecs相关

on

on

eni-service

Ecs网卡相关

on

on

firewalld

Centos7的默认防火墙

on

off

getty

tty控制台相关 保留

on

on

htcacheclean

Apache清除磁盘缓存

off

off

httpd

http服务器

off

off

看需要,可用Nginx代替

ip6tables

ipv6防火墙

on

off

不用ipv6就关闭

iptables

ipv4防火墙

on

on

看需要,阿里云安全组可代替

irqbalance

cpu负载均衡

on

on

多核cpu需要

iscsi

网络存储相关,san

on

off

看需要

iscsid

网络存储相关,san

on

off

kdump

内核崩溃信息捕获

on

on

看需要

lvm2-monitor

Lvm监控

on

on

有lvm就开

mdmonitor

软raid监控

on

on

建议开

microcode

处理器稳定性增强 保留

on

on

multipathd

off

off

NetworkManager-wait-online

网卡守护进程 关闭

on

off

netconsole

网络驱动程序调试用

off

off

netfs

网络文件系统

on

off

有用nfs可以开

network

启动是激活网络接口

on

on

必须开

nscd

name cache,应该与DNS相关

off

off

ntpd

自动对时服务

on

on

ntpdate

自动对时服务

off

off

php-fpm

Php解释器

off

off

用到开

postfix

替代sendmail的邮件服务器

on

off

rdisc

自动检测路由器

off

off

restorecond

selinux相关

off

off

用selinux就开

rsyslog

系统的日志服务

on

on

必须开

saslauthd

sasl认证服务相关

off

off

sshd

ssh服务端

on

on

必须开

svnserve

Svn服务端

off

off

服务端开,客户端关闭

sysstat

系统状态监测命令提供 iostat 和 sar

on

on

systemd-readahead-collect

内核调用--预读取 保留

on

on

systemd-readahead-drop

--

systemd-readahead-replay

--

dm-event

设备映射用

on

on

udev-post

设备管理系统

on

on

xinetd

超级守护进程

on

off

用到可以开

remote-fs.target

远程挂载文件系统

on

off

用到再开

runlevel2.target

运行级别 用于兼容6的SysV

on

on

runlevel3.target

--

on

on

runlevel4.target

--

on

on

转载于:https://www.cnblogs.com/doublexi/p/9729921.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/76482
推荐阅读
相关标签
  

闽ICP备14008679号