- 创建者: 虚拟的现实,上次更新时间:5月 05, 2025 需要 8 分钟阅读时间
简介
Cockpit 是 RedHat 维护的 Linux 服务器面板工具。它具备很强的开放能力,可以集成各种应用到面板的菜单上,如果善于使用它,你会发现它就是容器时代最好的面板之一。
官方网站:http://cockpit-project.org/
配置操作系统镜像
source.list 格式
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
Deb822 格式
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
Cockpit 组件安装
获取 并安装 Cockpit 组件
要获取最新版本,建议启用 backports 存储库(以 root 身份)
默认情况下通过 web 页面是不能直接用 root 用户登录的,新建一个管理用户 admin 并将该用户加入 sudo 组
. /etc/os-release echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > \ /etc/apt/sources.list.d/backports.list apt update apt install -t ${VERSION_CODENAME}-backports cockpit useradd admin passwd admin usermod -aG sudo admin
完成安装后可以通过浏览器访问 http://XXX:9090 方式打开配置页面
虚拟机和容器配置组件
. /etc/os-release apt install -t ${VERSION_CODENAME}-backports cockpit-machines -y apt install -t ${VERSION_CODENAME}-backports cockpit-podman -y
第三方组件(文件浏览、权限、共享)
配置45Drives Repo安装脚本,安装脚本将自动检测您的发行版并将适当的文件添加到您的系统。该脚本还将保存任何与 45Drives 相关的旧存储库(如果存在)。包括
cockpit-navigator、cockpit-file-sharing 和 cockpit-identities 这三个组件。
curl -sSL https://repo.45drives.com/setup | bash sudo apt update sudo apt install cockpit-navigator cockpit-file-sharing cockpit-identities -y
ZFS 组件
该插件按需安装,非必要组件。要求:Cockpit: 201+;NFS (Optional);Samba: 4+ (Optional);ZFS: 0.8+
apt update apt install -y zfs-dkms zfsutils-linux git clone https://github.com/optimans/cockpit-zfs-manager.git sudo cp -r cockpit-zfs-manager/zfs /usr/share/cockpit
Cockpit 调优
自动注销闲置的用户
在您首选的文本编辑器中,在 /etc/cockpit/ 目录中打开或创建 cockpit.conf 文件。
在文件中添加以下文本,以分钟为单位,这里表示为15分钟后自动退出。重启服务后生效。
vim /etc/cockpit/cockpit.conf [Session] IdleTimeout=10 systemctl try-restart cockpit
在登录页面中添加标题
在您首选的文本编辑器中创建 /etc/issue.cockpit 文件(如果您还没有该文件)。添加您要显示的内容作为文件的横幅。在文件中添加需要展示的内容。
vim /etc/cockpit/issue.cockpit HomeNAS Based on Debian 12.
内容添加完成后,保存这个文件。在 /etc/cockpit/ 目录中打开或创建 cockpit.conf 文件。在文件中添加以下文本,保存该文件,重启Cockpit Web 控制台以使更改生效。
[Session] Banner=/etc/cockpit/issue.cockpit systemctl try-restart cockpit
修改登录后的展示信息
配置文件路径及展示的原文内容如下:
vim /etc/motd The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
将上面的内容修改为:
我们信任您已经从系统管理员那里了解了日常注意事项。 总结起来无外乎这三点: #1) 尊重别人的隐私。 #2) 输入前要先考虑(后果和风险)。 #3) 权力越大,责任越大。
Nginx 反向代理 Cockpit
在 /etc/cockpit/ 目录中打开或创建 cockpit.conf 文件,在文件中添加以下文本,将下面内容中的两处’cockpit.domain.tld’替换为你的域名(如为非标端口号,需将端口号一并填写上),将192.168.1.10:9090修改为你对应的内网IP,就可以实现外网内网同时访问Cockpit管理面板
vim /etc/cockpit/cockpit.conf [WebService] Origins = https://cockpit.domain.tld wss://cockpit.domain.tld https://192.168.1.10:9090 ProtocolHeader = X-Forwarded-Proto ForwardedForHeader = X-Forwarded-For LoginTo = false systemctl try-restart cockpit
修改 Web 登陆端口
要更改其端口和/或地址,将以下内容放入文件中。在该路径中创建尚不存在的文件和目录。该ListenStream 选项指定所需的地址和 TCP 端口
注意:第一行的空值是故意的。systemd允许Listen在单个套接字单元中声明多个指令;插入文件中的空值会重置列表,从而禁用原始设备的默认端口 9090
vim /etc/systemd/system/cockpit.socket.d/listen.conf [Socket] ListenStream= ListenStream=443 systemctl daemon-reload systemctl restart cockpit.socket
设置 cockpit 接管网络配置
编辑文件网络配置文件,注销掉里面所有内容
vim /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # source /etc/network/interfaces.d/* # The loopback network interface # auto lo # iface lo inet loopback # The primary network interface # allow-hotplug enp1s0 # iface enp1s0 inet dhcp
登录 【Cockpit】-【网络】-【接口】- 【enp3s0 】(你网络接口名称)-IPV4-编辑-手动,输入你要设置的IP地址及默认网关。
交换空间优化
Debian默认是当内存使用达到**40%就向交换空间写入数据,这样会大大的降低电脑运行效率,将它改为10%**再向交换空间写入数据。打开 /etc/sysctl.conf 文件修改内容
vim /etc/sysctl.conf vm.swappiness=10 vm.vfs_cache_pressure=50 sysctl -p
- vm.swappiness 是用来控制内核在什么时候开始使用交换空间的参数,默认值是 60。将该值调整为 10 表示让内存使用率达到 90% 时才开始使用交换空间。
- vm.vfs_cache_pressure 是用来控制内核清理缓存的频率的参数,默认值是 100。将该值调整为 50 表示内核会更倾向于清理文件系统缓存以回收内存。
安装 Tuned 系统调优工具
Tuned(又称为tuned-adm)是一个系统调优工具,旨在帮助优化系统的性能和功耗。它允许管理员根据系统的需求选择不同的预定义配置文件或自定义配置文件,以提供最佳的性能和功耗平衡。
apt update && sudo apt install tuned
- systemctl start tuned:启动Tuned服务。
- systemctl stop tuned:停止Tuned服务。
- systemctl restart tuned:重启Tuned服务。
- systemctl status tuned:查看Tuned服务的运行状态。
- systemctl stop tuned:停止Tuned服务。
- systemctl disable tuned:禁止Tuned服务开机启动。
- tuned-adm list:列出所有可用的Tuned配置文件。
- tuned-adm active:查看当前活动的Tuned配置文件。
- tuned-adm recommend:根据系统的硬件配置和工作负载推荐一个最佳的Tuned配置文件。
常用TuneD 配置集
1、throughput-performance。针对高吞吐量优化的服务器配置文件。它禁用节能机制并启用 sysctl 设置,以提高磁盘和网络 IO 的吞吐量性能。CPU 调控器设置为 performance。它将 energy_performance_preference 和 scaling_governor 属性设置为 performance 配置集。
2、accelerator-performance。accelerator-performance 配置集包含与 throughput-performance 配置集相同的调整。另外,它会将 CPU 锁定为低 C 状态,以便使延迟小于 100us。这提高了某些加速器的性能,如 GPU。
3、network-throughput。用于吞吐量网络调优的配置集。它基于 throughput-performance 配置集。此外,它还增加了内核网络缓冲区。它继承 latency-performance 或 throughput-performance 配置集,并将energy_performance_preference 和 scaling_governor 属性改为 performance 配置集。
4、Balanced。默认的节能配置文件。它在性能和功耗之间具有折衷。在可能的情况下尽可能使用自动扩展和自动调整。唯一缺陷是增加延迟。在当前的 TuneD 版本中,它启用了 CPU、磁盘、音频和视频插件,并激活了 conservative CPU 调控器。如果支持,radeon_powersave 选项使用 dpm-balanced 值,否则被设置为 auto。它将 energy_performance_preference 属性改为 normal 能源设置。它还将 scaling_governor 策略属性改为 conservative 或 powersave CPU 调控器。
5、powersave。用于最大节能性能的配置集。它可以对性能进行调整,从而最大程度降低实际功耗。在当前的 TuneD 发行版本中,它为 SATA 主机适配器启用 USB 自动挂起、WiFi 节能和 Aggresive Link Power Management (ALPM) 节能。它还为使用低折率的系统调度多核功耗,并激活 ondemand 监管器。它启用了 AC97 音频节能,或根据您的系统,HDA-Intel 节能时间为 10 秒。如果您的系统包含启用了 KMS 支持的 Radeon 图形卡,配置集会将其配置为自动节能。在 ASUS Eee PC 上,启用了动态超级混合引擎。它将 energy_performance_preference 属性改为 powersave 或 power energy 设置。它还会将 scaling_governor 策略属性更改为 ondemand 或 powersave CPU 调控器。
安全配置
安全的概念:
1、收紧安全措施有可能达到使系统无法使用的程度。安全性与便利性需要得到平衡。诀窍在于建立一个安全且有用的系统。
2、最大的威胁是(并且一直都会是)用户。
3、最小权限原则:系统的每一部分应该只能访问到它确实需要的东西,除此之外的则不可以。
4、纵深防御:多个独立的层次能带来更好的安全性。当一层防护被攻破时,另一层应该能够阻止攻击。
5、保持一点点的偏执和多疑。如果有件事看起来太好了,不像是真的,那可能确实如此。
6、永远无法令系统 100% 安全,除非把机器从网络上断开,关掉电源,锁进保险柜,用混凝土封住并不再使用它。
7、为失败做好准备。预先为安全措施被攻破的情况制定可供执行的计划。
执行下列操作前,先给系统用户做个检查。检查是否存在空口令和root权限的账号,确认是否存在异常账号,确认UID为零的账号只有root账号。
awk -F: '($3==0)' /etc/passwd awk -F: '($2=="")' /etc/shadow
配置高强度密码策略
为了确保系统的安全性,建议设置的口令复杂度策略为:口令最小长度不小于8,至少包含大写字母、小写字母、数字和特殊字符中的三种。
安装 PAM 的 pwquality 模块,cracklib 模块在 Debian 1 2中被 pwquality 替代,pwquality 能提供额外的密码检查能力。
找到配置文件中关于 password requisite pam_pwquality.so retry=3 minlen=8 difok=3 的内容,添加参数“minlen”、“dcredit”、“ucredit”、“lcredit”、“ocredit”。如果文件中已有这些参数,直接修改参数值即可。
apt install libpam-pwquality vim /etc/pam.d/common-password password requisite pam_pwquality.so retry=3 minlen=9 dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1 difok=3
参数 | 说明 | 示例 |
minlen | "口令最小长度配置项。 PAM默认使用了“credits”,因此最小口令长度需要加1,若需要设置最小口令长度为8,则minlen的值应该设置为9。" | minlen=9 |
dcredit | "口令数字要求的配置项。 值为负数N时表示至少有N个数字,值为正数时对数字个数没有限制。" | dcredit=-1 |
ucredit | "口令大写字母要求的配置项。 值为负数N时表示至少有N个大写字母,值为正数时对大写字母个数没有限制。" | ucredit=-1 |
lcredit | "口令小写字母要求的配置项。 值为负数N时表示至少有N个小写字母,值为正数时对小写字母个数没有限制。" | lcredit=-1 |
ocredit | 特殊字符要求的配置项。 值为负数N时表示至少有N个特殊字符,值为正数时对特殊字符个数没有限制。 | ocredit=-1 |
用户连续登陆失败锁定
在3次登录尝试失败后账户将被锁定至少15分钟,或者由管理员将其解锁。在 /etc/pam.d/common-auth 中添加如下内容,必须按下面顺序添加
vim /etc/pam.d/common-auth # # /etc/pam.d/common-auth - authentication settings common to all services # # This file is included from other service-specific PAM config files, # and should contain a list of the authentication modules that define # the central authentication scheme for use on the system # (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the # traditional Unix authentication mechanisms. # # As of pam 1.0.1-6, this file is managed by pam-auth-update by default. # To take advantage of this, it is recommended that you configure any # local modules either before or after the default block, and use # pam-auth-update to manage selection of other modules. See # pam-auth-update(8) for details. # here are the per-package modules (the "Primary" block) auth required pam_faillock.so preauth audit silent deny=3 fail_interval=900 unlock_time=900 even_deny_root root_unlock_time=900 auth [success=1 default=ignore] pam_unix.so nullok # here's the fallback if no module succeeds # BEGIN ANSIBLE MANAGED BLOCK auth [default=die] pam_faillock.so authfail audit deny=3 fail_interval=900 unlock_time=900 even_deny_root root_unlock_time=900 auth sufficient pam_faillock.so authsucc audit deny=3 fail_interval=900 unlock_time=900 even_deny_root root_unlock_time=900 auth requisite pam_deny.so # prime the stack with a positive return value if there isn't one already; # this avoids us returning an error just because nothing sets a success code # since the modules above will each just jump around auth required pam_permit.so # and here are more per-package modules (the "Additional" block) auth optional pam_cap.so # end of pam-auth-update config
参数解析:
- audit #如果用户不存在,则把该用户名记录到系统日志中。
- Silent #不打印信息性的消息
- deny=3 #用户连续认证失败次数超过3则锁定
- fail_interval=900 #间隔时间的长度,在这个时间段内连续的
- unlock_time=900 #锁定后n秒后,访问将被重新启用,在没有设置faillock的情况下,不会重新启用。
- even_deny_root #Root账户和普通账户一样可以被锁定。
- root_unlock_time=900 #在root账户被锁定后, 允许在n秒后访问该账户。
参数解析来源 /etc/security/faillock.conf 文件
上述参数可以按需添加,如需全部添加,可以参考下面格式:
auth required pam_faillock.so preauth audit silent deny=3 fail_interval=900 unlock_time=900 even_deny_root root_unlock_time=900
接着编辑/etc/pam.d/common-account 插入内容(灰色部分为默认自带内容)
vim /etc/pam.d/common-account # # /etc/pam.d/common-account - authorization settings common to all services # # This file is included from other service-specific PAM config files, # and should contain a list of the authorization modules that define # the central access policy for use on the system. The default is to # only deny service to users whose accounts are expired in /etc/shadow. # # As of pam 1.0.1-6, this file is managed by pam-auth-update by default. # To take advantage of this, it is recommended that you configure any # local modules either before or after the default block, and use # pam-auth-update to manage selection of other modules. See # pam-auth-update(8) for details. # # here are the per-package modules (the "Primary" block) account [success=1 new_authtok_reqd=done default=ignore] pam_unix.so # here's the fallback if no module succeeds account requisite pam_deny.so # prime the stack with a positive return value if there isn't one already; # this avoids us returning an error just because nothing sets a success code # since the modules above will each just jump around account required pam_permit.so # and here are more per-package modules (the "Additional" block) # end of pam-auth-update config account required pam_faillock.so
常用操作命令
- faillock 查看所有用户的尝试失败登录次数。主要看faillock命令,显示的valid值,v表示有效,i表示无效。
- faillock --user test 查看指定用户(test用户)
- faillock --user test --reset 解锁指定用户账户(test用户)
- faillock --reset 解锁所有用户
- 重启系统也能解锁所有用户
禁止root用户密码登陆
建议是通过 Cockpit Web 管理面板禁止 roo t用户密码登陆,平时保持其处于禁用状态,如有需要时可以很方便就通过此处开启,用完即随手关闭。
通过 Cockpit Web 管理面板-【账户】-【root用户】-【选项】-【禁用交互式密码】,打上勾表示禁止 root 用户使用密码登陆。
限制用户 SU
限制能 su 到 root 的用户,修改配置文件,在配置文件中添加行。例如,只允许 sudo 组用户 su 到 root,则添加
vim /etc/pam.d/su # # The PAM configuration file for the Shadow `su' service # auth required pam_wheel.so group=sudo # This allows root to su without passwords (normal operation) auth sufficient pam_rootok.so
用户登陆邮件通知告警
通过 PAM 模块,就可以实现用户登录,root 权限获取时,通过邮件等方式进行通知。以实现,预先知道,预先警惕的目标,降低受影响的范围。以下是通过 PAM 模块实现的邮件通知用户登录的功能。
1、以管理员身份登录虚拟机,并切换成 root 用户。
2、新建脚本
vim /etc/pam.d/login-notifiy.sh #!/bin/bash export LANG="en_US.UTF-8" [ "$PAM_TYPE" = "open_session" ] || exit 0 { echo "用户: $PAM_USER" echo "远程用户: $PAM_RUSER" echo "远程主机: $PAM_RHOST" echo "服务: $PAM_SERVICE" echo "终端: $PAM_TTY" echo "日期: `date '+%Y年%m月%d日%H时%M分%S秒'`" echo "服务器: `uname -s -n -r`" } | mail -s "注意! 用户$PAM_USER正通过$PAM_SERVICE服务登录`hostname -s | awk '{print toupper(substr($0,1,1)) substr($0,2)}'`系统" user@yourdomain.com vim /etc/pam.d/common-session session optional pam_exec.so debug /bin/bash /etc/pam.d/login-notifiy.sh
每一个用户登录都会发邮件通知给收件人,内容包括用户名以及登录的 IP 地址信息。如果遇到陌生 IP,那么就要注意,该主机是否正在遭受攻击。
超时自动注销活动状态
设置系统登录后,连接超时时间,增强安全性。即超时时间为三分钟。
vim /etc/profile TMOUT=180
记录所有用户的登录和操作日志
过脚本代码实现记录所有用户的登录操作日志,防止出现安全事件后无据可查。
vim /etc/profile # 在 history 命令中启用时间戳 export HISTTIMEFORMAT="%F %T " # 记录所有用户的登录和操作日志 history USER=`whoami` USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'` if [ "$USER_IP" = "" ]; then USER_IP=`hostname` fi if [ ! -d /var/log/history ]; then mkdir /var/log/history chmod 777 /var/log/history fi if [ ! -d /var/log/history/${LOGNAME} ]; then mkdir /var/log/history/${LOGNAME} chmod 300 /var/log/history/${LOGNAME} fi export HISTSIZE=4096 DT=`date +"%Y%m%d_%H:%M:%S"` export HISTFILE="/var/log/history/${LOGNAME}/${USER}@${USER_IP}_$DT" chmod 600 /var/log/history/${LOGNAME}/*history* 2>/dev/null bash -c "source /etc/profile"
通过上述步骤,可以在 /var/log/history 目录下以每个用户为名新建一个文件夹,每次用户退出后都会产生以用户名、登录IP、时间的日志文件,包含此用户本次的所有操作(root用户除外)。
安装防火墙
推荐使用 firewalld 防火墙的理由是,Cockpit Web 管理面板搭配 firewalld 防火墙可以提供一个可视化的防火墙管理界面。从 apt 存储库安装 firewalld,并在安装成功之后关闭 firewalld,关闭之后进入 cockpit 配置规则。
登陆cockpit-【网络】-【防火墙】-【打开防火墙】-【添加新区】-【信任级别】- 【public】,允许的地址-整个子网
apt update && apt install firewalld -y && systemctl stop firewalld sudo systemctl status firewalld
在终端输出的内容中将看到:Active: active (running)
Firewalld 高阶使用
GeoIP 和 Firewalld 组合使用的常见案例主要涉及到基于地理位置的防火墙规则。
配置 fail2ban
自定义的配置也可以参考 https://wiki.waringid.me/x/IAES。
- Fail2Ban的配置文件:/etc/fail2ban/
- Fail2Ban的安装目录:/usr/share/fail2ban/
- Fail2Ban日志文件:/var/log/fail2ban.log
- 达到阈值之后的执行Fail2Ban的动作的配置文件:/etc/fail2ban/action.d/
- 包含Fail2Ban所有的过滤规则:/etc/fail2ban/filter.d/
- fail2ban 服务将其配置文件保存在该/etc/fail2ban目录中
apt update apt install fail2ban -y cp /etc/fail2ban/jail.{conf,local} vim /etc/fail2ban/jail.local #backend = auto #Debian12使用systemd才能正常启动fail2ban backend = systemd #这定义了是否使用反向 DNS 来帮助实施禁令。将此设置为“否”将禁止 IP 本身而不是其域主机名。该warn设置将尝试查找主机名并以这种方式禁止,但会记录活动以供审查。 usedns = warn #如果将您的操作配置为邮件警报,这是接收通知邮件的地址。 destemail = root@localhost #发送者邮件地址 sender = root@<fq-hostname> #这是用于发送通知电子邮件的邮件传输代理。 mta = mail #“action_”之后的“mw”告诉 Fail2ban 向您发送电子邮件。“mwl”也附加了日志。 action = %(action_mw)s #这是实施 IP 禁令时将丢弃的流量类型。这也是发送到新 iptables 链的流量类型。 protocol = tcp ##这里banaction必须用firewallcmd-ipset,这是fiewalll支持的关键,如果是用Iptables请不要这样填写 banaction = firewallcmd-ipset [SSH] enabled = true port = ssh filter = sshd logpath = /var/log/auth.log
配置中文邮件格式(可选项,默认为英文)
通过 curl ifconfig.co 获取服务器的外网IP地址,方便知道哪台机报出来的告警。通过 curl https://ip.useragentinfo.com/json?ip =<ip> 查询获取攻击者的IP信息。
cp /etc/fail2ban/action.d/mail-whois.{conf,local} vim /etc/fail2ban/action.d/mail-whois.local # Fail2Ban configuration file # # Author: Cyril Jaquier # # [INCLUDES] before = mail-whois-common.conf [Definition] # bypass ban/unban for restored tickets norestored = 1 # Option: actionstart # Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false). # Values: CMD # actionstart = printf %%b "你好!\n 监视到【<name>】服务已成功启动。\n 敬请注意!\n Fail2Ban"|mail -s "[Fail2Ban] <name>: 在 <fq-hostname> 服务器上启动" <dest> # Option: actionstop # Notes.: command executed at the stop of jail (or at the end of Fail2Ban) # Values: CMD # actionstop = printf %%b "你好!\n 监视到【<name>】服务已被停止。\n 敬请注意!\n Fail2Ban"|mail -s "[Fail2Ban] <name>: 在 <fq-hostname> 服务器上停止" <dest> # Option: actioncheck # Notes.: command executed once before each actionban command # Values: CMD # actioncheck = # Option: actionban # Notes.: command executed when banning an IP. Take care that the # command is executed with Fail2Ban user rights. # Tags: See jail.conf(5) man page # Values: CMD # actionban = printf %%b "警告!!!\n 攻击者IP:<ip>\n 被攻击机器名:`uname -n` \n 被攻击机器IP:`/bin/curl ifconfig.co` \n 攻击服务:<name> \n 攻击次数:<failures> 次 \n 攻击方法:暴力破解,尝试弱口令.\n 该IP:<ip>已经被Fail2Ban加入防火墙黑名单,屏蔽时间<bantime>秒.\n\n 以下是攻击者 <ip>信息 :\n `/bin/curl https://ip.appworlds.cn?ip=<ip>`\n\n Fail2Ban邮件提醒\n\n "|/bin/mailx -s "<fq-hostname>服务器:<name>服务疑似遭到<ip>暴力攻击。" <dest> # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the # command is executed with Fail2Ban user rights. # Tags: See jail.conf(5) man page # Values: CMD # actionunban = [Init] # Default name of the chain # name = default # Destination/Addressee of the mail # dest = root
安装病毒防护软件
ClamAV 是一个开源的防病毒软件,可用于检测木马,病毒,恶意软件和其他恶意威胁。适用于 Linux、macOS 和 Windows 平台。
apt-get update apt-get install clamav
更新病毒数据库
在安装完成后,需要运行以下命令来更新ClamAV的病毒数据库:
1、关闭ClamAV病毒数据库更新服务
systemctl stop clamav-freshclam
2、更新病毒数据库:
freshclam
3、启动ClamAV病毒数据库更新服务:
systemctl start clamav-freshclam
使用ClamAV
1、扫描整个系统:在终端窗口中输入以下命令,扫描整个系统:
clamscan -r /
2、扫描指定目录:在终端窗口中输入以下命令,扫描指定目录:
clamscan -r /path/to/directory
3、删除被感染的文件:在终端窗口中输入以下命令,删除被感染的文件:
clamscan --remove /path/to/file
4、扫描压缩文件:在终端窗口中输入以下命令,扫描压缩文件:
clamscan -r /path/to/archive.zip
5、执行定期扫描:在终端窗口中输入以下命令,创建一个每天执行一次的定期扫描:
crontab -e 0 0 * * * clamscan -r / > /var/log/clamav/scan.log
将在每天的午夜(0点)执行全系统扫描,并将扫描结果保存在/var/log/clamav/scan.log文件中。
参考:CentOS7 配置
Cockpit 支持 CentOS 7以及之后的版本
#安装cockpit: sudo yum install cockpit #启动 cockpit: sudo systemctl enable --now cockpit.socket #打开防火墙(非必须): sudo firewall-cmd --permanent --zone=public --add-service=cockpit sudo firewall-cmd --reload
https://docs.qq.com/doc/p/ac7a498302fca24ec7f0d002820ee32eceb03c13
- 无标签