通过 Chef 在 Linux 上部署 Defender for Endpoint

重要

本文包含有关第三方工具的信息。 这样做是为了帮助完成集成方案,但是,Microsoft不提供对第三方工具的故障排除支持。
请联系第三方供应商获取支持。

简介

可以使用各种工具和方法在 Linux 上部署 Defender for Endpoint。 本文介绍如何使用两种方法通过 Chef 在 Linux 上大规模部署 Defender for Endpoint:

  • 使用安装程序脚本安装
  • 手动配置存储库以更精细地控制部署

若要使用其他方法,请参阅 另请参阅 部分。

重要

如果要并行运行多个安全解决方案,请参阅 性能、配置和支持注意事项

你可能已经为载入到Microsoft Defender for Endpoint的设备配置了相互安全排除。 如果仍需要设置相互排除以避免冲突,请参阅将Microsoft Defender for Endpoint添加到现有解决方案的排除列表

先决条件

在开始之前,请参阅 Linux 上的 Defender for Endpoint 先决条件,了解先决条件和系统要求。

下载载入包

警告

不支持重新打包 Defender for Endpoint 安装包。 这样做可能会对产品的完整性产生负面影响,并导致不良结果,包括但不限于触发篡改警报和无法应用的更新。

  1. 登录到Microsoft Defender门户,然后导航到“系统>设置终结点>”>设备管理>载入”。

  2. 在第一个下拉菜单中,选择“Linux服务器”作为操作系统。 在第二个下拉菜单中,选择“你的首选Linux配置管理工具”作为部署方法。

  3. 选择 “下载载入包 ”,并将文件保存为 WindowsDefenderATPOnboardingPackage.zip

  4. 使用以下命令提取存档的内容:

    unzip WindowsDefenderATPOnboardingPackage.zip
    

    预期输出为:

    Archive:  WindowsDefenderATPOnboardingPackage.zip
    inflating: mdatp_onboard.json
    

创建目录结构

在开始之前,请确保已安装 Chef 组件,并且 Chef 存储库 (chef 生成的存储库 <>) 存在,以便存储用于部署到 Chef 托管Linux服务器上的 Defender for Endpoint 的指南。

以下命令为名为 mdatp 的新指南创建新的文件夹结构。 如果已有一本要用于添加 Defender for Endpoint 部署的指南,也可以使用现有指南。

chef generate cookbook mdatp

创建食谱后,在创建的食谱文件夹中创建一个文件文件夹:

mkdir mdatp/files

复制到 mdatp_onboard.json/tmp 文件夹。

在 Chef 工作站上,导航到 mdatp/recipes 文件夹,该文件夹在生成食谱时自动创建。 使用首选文本编辑器 ((如 vi 或 nano) )将以下说明添加到 default.rb 文件的末尾,然后保存并关闭该文件: include_recipe '::install_mdatp'

创建食谱

可以通过以下任一方法创建指南:

使用安装程序脚本创建指南

  1. 下载安装程序 bash 脚本。 从 Microsoft GitHub 存储库中拉取 安装程序 bash 脚本 ,或使用以下命令下载该脚本:

    wget https://raw.githubusercontent.com/microsoft/mdatp-xplat/refs/heads/master/linux/installation/mde_installer.sh /tmp
    
  2. 在 recipes 文件夹中~/cookbooks/mdatp/recipes/install_mdatp.rb创建名为 install_mdatp.rb 的新食谱文件,并将以下文本添加到该文件。 也可以直接从 GitHub 下载文件。

    mdatp = "/etc/opt/microsoft/mdatp"
    
    #Download the onboarding json from tenant, keep the same at specific location
    onboarding_json = "/tmp/mdatp_onboard.json"
    
    #Download the installer script from: https://github.com/microsoft/mdatp-xplat/blob/master/linux/installation/mde_installer.sh
    #Place the same at specific location, edit this if needed
    mde_installer= "/tmp/mde_installer.sh"
    
    
    ## Invoke the mde-installer script 
    bash 'Installing mdatp using mde-installer' do
        code <<-EOS
        chmod +x #{mde_installer}
        #{mde_installer} --install --onboard #{onboarding_json}
        EOS
    end
    

注意

安装程序脚本还支持其他参数,例如通道、实时保护、版本等。若要从可用选项列表中选择,请通过以下命令检查帮助:./mde_installer.sh --help

通过手动配置存储库创建指南

在 recipes 文件夹中~/cookbooks/mdatp/recipes/install_mdatp.rb创建名为 install_mdatp.rb 的新食谱文件,并将以下文本添加到该文件。 也可以直接从 Github 下载文件。

#Add Microsoft Defender
case node['platform_family']
when 'debian'
 apt_repository 'MDATPRepo' do
   arch               'amd64'
   cache_rebuild      true
   cookbook           false
   deb_src            false
   key                'BC528686B50D79E339D3721CEB3E94ADBE1229CF'
   keyserver          "keyserver.ubuntu.com"
   distribution       'jammy'
   repo_name          'microsoft-prod'
   components         ['main']
   uri                "https://packages.microsoft.com/ubuntu/22.04/prod"
 end
apt_package "mdatp"
when 'rhel'
 yum_repository 'microsoft-prod' do
   baseurl            "https://packages.microsoft.com/rhel/7/prod/"
   description        "Microsoft Defender for Endpoint"
   enabled            true
   gpgcheck           true
   gpgkey             "https://packages.microsoft.com/keys/microsoft.asc"
 end
 if node['platform_version'] <= 8 then
    yum_package "mdatp"
 else
    dnf_package "mdatp"
 end
end

#Create MDATP Directory
mdatp = "/etc/opt/microsoft/mdatp"
onboarding_json = "/tmp/mdatp_onboard.json"

directory "#{mdatp}" do
  owner 'root'
  group 'root'
  mode 0755
  recursive true
end

#Onboarding using tenant json 
file "#{mdatp}/mdatp_onboard.json" do
  content lazy { ::File.open(onboarding_json).read }
  owner 'root'
  group 'root'
  mode '0644'
  action :create_if_missing
end

注意

可以修改 os 分发、分发版本号、频道 (prod/insider-fast、insiders-slow) 和存储库名称,以匹配要部署到的版本和要部署到的通道。 运行 chef-client --local-mode --runlist 'recipe[mdatp]' 以在 Chef 工作站上测试食谱。

解决安装问题

若要排查问题,请:

  1. 有关如何查找发生安装错误时自动生成的日志的信息,请参阅 日志安装问题

  2. 有关常见安装问题的信息,请参阅 安装问题

  3. 如果设备的运行状况为 false,请参阅 Defender for Endpoint 代理运行状况问题

  4. 有关产品性能问题,请参阅 排查性能问题

  5. 有关代理和连接问题,请参阅 排查云连接问题。 若要从Microsoft获取支持,请打开支持票证,并使用 客户端分析器提供创建的日志文件。

如何为Linux上的Microsoft Defender配置策略

可以使用以下任一方法在终结点上配置防病毒或 EDR 设置:

卸载 MDATP 指南

若要卸载 Defender,请将以下内容保存为食谱 ~/cookbooks/mdatp/recipes/uninstall_mdatp.rb

#Uninstall the Defender package
case node['platform_family']
when 'debian'
 apt_package "mdatp" do
   action :remove
 end
when 'rhel'
 if node['platform_version'] <= 8
then
    yum_package "mdatp" do
      action :remove
    end
 else
    dnf_package "mdatp" do
      action :remove
    end
 end
end

若要将此步骤作为食谱的一部分包含在食谱中,请将 添加到 include_recipe ':: uninstall_mdatpdefault.rb recipe 文件夹中的 文件中。 确保已从default.rb文件中删除 。include_recipe '::install_mdatp'

另请参阅