关闭主机selinux脚本

关闭主机selinux脚本

#!/bin/bash

sed -i “s/^SELINUX=.*$/SELINUX=disabled/” /etc/selinux/config
#修改selinux配置文件,关闭selinux

systemctl disable firewalld
#设置开机禁用防火墙

systemctl disable NetworkManager
#永久关闭网络管理命令

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于 Windows 主机加固,可以使用以下脚本: ``` # 关闭不必要的服务 sc stop wuauserv sc config wuauserv start=disabled sc stop RemoteRegistry sc config RemoteRegistry start=disabled sc stop SSDPSRV sc config SSDPSRV start=disabled # 禁用不必要的端口 netsh advfirewall firewall add rule name="Block Port 135" dir=in action=block protocol=TCP localport=135 netsh advfirewall firewall add rule name="Block Port 137" dir=in action=block protocol=UDP localport=137 netsh advfirewall firewall add rule name="Block Port 138" dir=in action=block protocol=UDP localport=138 netsh advfirewall firewall add rule name="Block Port 139" dir=in action=block protocol=TCP localport=139 netsh advfirewall firewall add rule name="Block Port 445" dir=in action=block protocol=TCP localport=445 # 修改本地策略 secedit /export /cfg C:\secpol.cfg (Get-Content C:\secpol.cfg).replace("PasswordComplexity = 1", "PasswordComplexity = 0") | Set-Content C:\secpol.cfg secedit /configure /db %windir%\security\local.sdb /cfg C:\secpol.cfg /areas SECURITYPOLICY # 禁止自动运行 reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "NoAutoplayfornonVolume" /t REG_DWORD /d "1" /f # 禁用 SMBv1 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 -Force Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" SMB1 -Type DWORD -Value 0 -Force ``` 对于 Linux 主机加固,可以使用以下脚本: ``` # 更新系统 yum update -y # 禁用不必要的服务 systemctl stop xinetd systemctl disable xinetd systemctl stop avahi-daemon.socket avahi-daemon.service systemctl disable avahi-daemon.socket avahi-daemon.service systemctl stop cups.socket cups.service systemctl disable cups.socket cups.service # 设置防火墙 firewall-cmd --zone=public --add-port=22/tcp --permanent firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload # 修改SSH设置,禁用root登录 sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config systemctl restart sshd # 安装 SELinux yum install selinux-policy selinux-policy-targeted -y ``` 以上脚本仅供参考,具体根据实际情况进行修改和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值