你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
本文介绍了 VM 和操作系统的安全最佳做法。
最佳做法以观点的共识以及 Azure 平台功能和特性集为基础。 由于观点和技术会随时改变,本文会进行更新以反映这些变化。
在大多数基础结构即服务 (IaaS) 方案中,Azure 虚拟机 (VM) 是使用云计算的组织的主要工作负荷。 This fact is evident in hybrid scenarios where organizations want to slowly migrate workloads to the cloud. 在这种方案中,应遵循 IaaS 常规安全注意事项,并向所有 VM 应用安全最佳做法。
通过身份验证和访问控制保护 VM
保护 VM 安全的第一步是确保只有授权用户才能设置新 VM 以及访问 VM。
Note
若要改进 Azure 上 Linux VM 的安全性,可以与 Microsoft Entra 身份验证集成。 将 Microsoft Entra 身份验证用于 Linux VM 时,可以通过集中控制和强制实施策略来允许或拒绝对 VM 的访问。
Best practice: Control VM access. Detail: Use Azure policies to establish conventions for resources in your organization and create customized policies. Apply these policies to resources, such as resource groups. 属于该资源组的 VM 将继承该组的策略。
如果你的组织有多个订阅,则可能需要一种方法来高效地管理这些订阅的访问权限、策略和符合性。 Azure 管理组提供订阅上的作用域级别。 可将订阅组织到管理组(容器)中,并将管理条件应用到该组。 管理组中的所有订阅都将自动继承应用于该组的条件。 不管使用什么类型的订阅,管理组都能提供大规模的企业级管理。
Best practice: Reduce variability in your setup and deployment of VMs. Detail: Use Azure Resource Manager templates to strengthen your deployment choices and make it easier to understand and inventory the VMs in your environment.
Best practice: Secure privileged access. Detail: Use a least privilege approach and built-in Azure roles to enable users to access and set up VMs:
- 虚拟机参与者:可以管理 VM,但无法管理虚拟机连接的虚拟网络或存储帐户。
- 经典虚拟机参与者:可管理使用经典部署模型创建的 VM,但无法管理这些 VM 连接到的虚拟网络或存储帐户。
- Security Admin: In Defender for Cloud only: Can view security policies, view security states, edit security policies, view alerts and recommendations, dismiss alerts and recommendations.
- 开发测试实验室用户:可以查看所有内容,以及连接、启动、重新启动和关闭 VM。
订阅管理员和共同管理员可更改此设置,使其成为订阅中所有 VM 的管理员。 请确保你信任所有订阅管理员和共同管理员,以登录你的任何计算机。
Note
建议将具有相同生命周期的 VM 合并到同一个资源组中。 使用资源组可以部署和监视资源,并统计资源的计费成本。
控制 VM 访问和设置的组织可改善其整体 VM 安全性。
使用虚拟机规模集实现高可用性
如果 VM 运行需要高可用性的关键应用程序,强烈建议使用 虚拟机规模集。
使用虚拟机规模集可以创建和管理一组负载均衡的 VM。 可以根据需求或定义的计划自动增减 VM 实例的数目。 规模集为应用程序提供高可用性,用于集中管理、配置和更新大量 VM。 规模集本身是免费的,你只需为创建的每个 VM 实例付费。
规模集内的虚拟机还可部署到多个可用性区域、单个可用性区域或按地区进行部署。
防范恶意软件
应安装反恶意软件保护,以帮助识别和删除病毒、间谍软件和其他恶意软件。 You can install Microsoft Antimalware or a Microsoft partner's endpoint protection solution (Trend Micro, Broadcom, McAfee, Windows Defender, and System Center Endpoint Protection).
Microsoft 反恶意软件包括实时保护、计划扫描、恶意软件修正、签名更新、引擎更新、示例报告和排除事件收集等功能。 对于与生产环境分开托管的环境,可以使用反恶意软件扩展来帮助保护 VM 和云服务。
你可以将 Microsoft Antimalware 和合作伙伴解决方案与 Microsoft Defender for Cloud 集成,以便轻松部署和内置检测(警报和事件)。
Best practice: Install an antimalware solution to protect against malware.
Detail: Install a Microsoft partner solution or Microsoft Antimalware
Best practice: Integrate your antimalware solution with Defender for Cloud to monitor the status of your protection.
Detail: Manage endpoint protection issues with Defender for Cloud
管理 VM 更新
与所有本地 VM 一样,Azure VM 应由用户管理。 Azure 不会向他们推送 Windows 更新。 你需要管理 VM 更新。
Best practice: Keep your VMs current.
Detail: Use the Update Management solution in Azure Automation to manage operating system updates for your Windows and Linux computers that are deployed in Azure, in on-premises environments, or in other cloud providers. 可以快速评估所有代理计算机上可用更新的状态,并管理为服务器安装所需更新的过程。
由更新管理托管的计算机使用以下配置执行评估和更新部署:
- 用于 Windows 或 Linux 的 Microsoft 监视代理 (MMA)
- 用于 Linux 的 PowerShell 所需状态配置 (DSC)
- 自动化混合 Runbook 辅助角色
- 适用于 Windows 计算机的 Microsoft 更新或 Windows Server 更新服务 (WSUS)
若使用 Windows 更新,请启用 Windows 自动更新设置。
Best practice: Ensure at deployment that images you built include the most recent round of Windows updates.
Detail: Check for and install all Windows updates as a first step of every deployment. 在部署自己或库中提供的映像时,采用此措施就特别重要。 虽然默认情况下会自动更新 Azure 市场中的映像,但公开发布后可能会有延迟(最多几周)。
Best practice: Periodically redeploy your VMs to force a fresh version of the OS.
Detail: Define your VM with an Azure Resource Manager template so you can easily redeploy it. 使用模板可在需要时提供已修补且安全的 VM。
Best practice: Rapidly apply security updates to VMs.
Detail: Enable Microsoft Defender for Cloud (Free tier or Standard tier) to identify missing security updates and apply them.
Best practice: Install the latest security updates.
Detail: Some of the first workloads that customers move to Azure are labs and external-facing systems. 如果 Azure VM 托管需要访问 Internet 的应用程序或服务,则需要警惕修补。 修补不仅仅包括操作系统。 合作伙伴应用程序上未修补的漏洞还可能导致一些问题,而如果实施良好的修补程序管理,就可以避免这些问题。
Best practice: Deploy and test a backup solution.
Detail: A backup needs to be handled the same way that you handle any other operation. 这适合于属于扩展到云的生产环境的系统。
测试和开发系统必须遵循备份策略,这些策略可以根据用户的本地环境体验,提供与用户习惯的功能类似的存储功能。 如果可能,迁移到 Azure 的生产工作负荷应与现有的备份解决方案集成。 Or, you can use Azure Backup to help address your backup requirements.
未实施软件更新策略的组织面临更多利用已修复的已知漏洞的威胁。 为了遵守行业法规,公司还必须证明他们在不断作出相应努力并使用正确的安全控制机制来帮助确保云中工作负载的安全性。
传统数据中心与 Azure IaaS 之间的软件更新最佳做法存在许多相似之处。 建议评估当前的软件更新策略,将位于 Azure 中的 VM 包含在内。
管理 VM 安全状况
网络威胁不断加剧。 保护 VM 需要监视功能,以便快速检测威胁、防止有人未经授权访问资源、触发警报并减少误报。
To monitor the security posture of your Windows and Linux VMs, use Microsoft Defender for Cloud. 在 Defender for Cloud 中,系统利用以下功能来保护 VM:
- 应用包含建议的配置规则的 OS 安全设置。
- 识别并下载可能缺少的系统安全更新和关键更新。
- 部署终结点反恶意软件防护建议措施。
- 验证磁盘加密。
- 评估并修正漏洞。
- Detect threats.
Defender for Cloud 可以主动监视威胁,并在安全警报中公开潜在威胁。 关联的威胁将合并到名为“安全事件”的单个视图中。
Defender for Cloud 将数据存储在 Azure Monitor 日志中。 Azure Monitor 日志提供查询语言和分析引擎,让你能够深入了解应用程序和资源的操作。 Data is also collected from Azure Monitor, management solutions, and agents installed on virtual machines in the cloud or on-premises. 可以通过此共享功能全面了解自己的环境。
没有为 VM 实施强大安全措施的组织将意识不到未经授权的用户可能试图绕过安全控制机制。
监视 VM 性能
如果 VM 进程消耗的资源多过实际所需的量,可能会造成资源滥用的问题。 VM 性能问题可能会导致服务中断,从而违反可用性安全原则。 这对于托管 IIS 或其他 Web 服务器的 VM 尤其重要,因为 CPU 或内存占用较高可能意味着遭到拒绝服务 (DoS) 攻击。 不仅要在出现问题时被动监视 VM 的访问,而且还要在正常运行期间针对基准性能进行主动监视。
We recommend that you use Azure Monitor to gain visibility into your resource’s health. Azure Monitor 功能:
- 资源诊断日志文件:监视 VM 资源并识别可能会损害性能与可用性的潜在问题。
- Azure 诊断扩展:在 Windows VM 上提供监视和诊断功能。 在 Azure 资源管理器模板中包含该扩展即可启用这些功能。
不监视 VM 性能的组织无法确定性能模式的某些变化是正常还是异常。 若 VM 消耗的资源超过平常,可能意味着存在来自外部资源的攻击,或者此 VM 中有不安全的进程正在运行。
加密虚拟硬盘文件
建议加密虚拟硬盘 (VHD),以帮助保护存储中的静态启动卷和数据卷以及加密密钥和机密。
适用于 Linux VM 的 Azure 磁盘加密和适用于 Windows VM 的 Azure 磁盘加密可帮助加密 Linux 和 Windows IaaS 虚拟机磁盘。 Azure Disk Encryption uses the industry-standard DM-Crypt feature of Linux and the BitLocker feature of Windows to provide volume encryption for the OS and the data disks. 该解决方案与 Azure Key Vault 集成,帮助用户管理 Key Vault 订阅中的磁盘加密密钥和机密。 此解决方案还可确保虚拟机磁盘上的所有数据在 Azure 存储中静态加密。
下面是使用 Azure 磁盘加密的最佳做法:
Best practice: Enable encryption on VMs.
Detail: Azure Disk Encryption generates and writes the encryption keys to your key vault. 在密钥保管库中管理加密密钥需要 Microsoft Entra 身份验证。 为此创建 Microsoft Entra 应用程序。 对于身份验证,可以使用基于客户端密码的身份验证或基于客户端证书的 Microsoft Entra 身份验证。
Best practice: Use a key encryption key (KEK) for an additional layer of security for encryption keys. 将 KEK 添加到密钥保管库。
Detail: Use the Add-AzKeyVaultKey cmdlet to create a key encryption key in the key vault. 还可从本地硬件安全模块 (HSM) 导入 KEK 以进行密钥管理。 有关详细信息,请参阅 Key Vault 文档。 指定密钥加密密钥后,Azure 磁盘加密会使用该密钥包装加密机密,然后将机密写入 Key Vault。 在本地密钥管理 HSM 中保留此密钥的托管副本,提供额外的保护,防止意外删除密钥。
Best practice: Take a snapshot and/or backup before disks are encrypted. 如果加密期间发生意外故障,备份可提供恢复选项。
Detail: VMs with managed disks require a backup before encryption occurs. After a backup is made, you can use the Set-AzVMDiskEncryptionExtension cmdlet to encrypt managed disks by specifying the -skipVmBackup parameter. For more information about how to back up and restore encrypted VMs, see the Azure Backup article.
Best practice: To make sure the encryption secrets don’t cross regional boundaries, Azure Disk Encryption needs the key vault and the VMs to be located in the same region.
Detail: Create and use a key vault that is in the same region as the VM to be encrypted.
Azure 磁盘加密可解决以下业务需求:
- 使用行业标准的加密技术轻松保护 IaaS VM,满足组织的安全性与合规性要求。
- IaaS VM 会根据客户控制的密钥和策略启动,客户可以在 Key Vault 中审核密钥和策略的使用方式。
限制直接 Internet 连接
监视和限制 VM 直接 Internet 连接。 攻击者可能会不断利用猜出的常用密码和已知的未修补漏洞,扫描公有云 IP 范围中的开放管理端口,然后试图发起“轻而易举”的攻击。 下表列出了有助于防范这些攻击的最佳做法:
Best practice: Prevent inadvertent exposure to network routing and security.
Detail: Use Azure RBAC to ensure that only the central networking group has permission to networking resources.
Best practice: Identify and remediate exposed VMs that allow access from “any” source IP address.
Detail: Use Microsoft Defender for Cloud. 如果任何网络安全组具有一个或多个允许从“任何”源 IP 地址访问的入站规则,Defender for Cloud 将建议通过面向 Internet 的终结点限制访问。 Defender for Cloud will recommend that you edit these inbound rules to restrict access to source IP addresses that actually need access.
Best practice: Restrict management ports (RDP, SSH).
Detail: Just-in-time (JIT) VM access can be used to lock down inbound traffic to your Azure VMs, reducing exposure to attacks while providing easy access to connect to VMs when needed. 启用 JIT 后,通过创建网络安全组规则,Defender for Cloud 会锁定 Azure VM 的入站流量。 你需要选择要锁定 VM 上的哪些端口的入站流量。 这些端口将受 JIT 解决方案控制。
Next steps
有关通过 Azure 设计、部署和管理云解决方案时可以使用的更多安全最佳做法,请参阅 Azure 安全最佳做法和模式。
以下资源提供了有关 Azure 安全性及相关 Microsoft 服务的更多常规信息:
- Azure 安全团队博客 - 随时掌握 Azure 安全性的最新信息
- Microsoft 安全响应中心 - 可在其中报告 Microsoft 安全漏洞(包括 Azure 问题)或将其通过电子邮件发送到 secure@microsoft.com