步骤 4:SSM Agent为混合和多云环境安装 () Windows - Amazon Systems Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

步骤 4:SSM Agent为混合和多云环境安装 () Windows

本主题介绍如何在混合和多云环境的Windows Server计算机SSM Agent上安装。如果您计划在混合和多云环境中使用非 EC2 Linux 计算机,请参阅之前的步骤:。步骤 3:在混合和多云环境中安装SSM Agent (Linux)

重要

此过程是混合云和多云环境中的非 EC2(亚马逊弹性计算云)计算机。要在适用于 Windows Server 的 EC2 实例上下载并安装 SSM Agent,请参阅 在适用于 Windows Server 的 EC2 实例上使用 SSM Agent

在开始前,找到之前在中完成混合激活后收到的激活代码和激活 ID 步骤 2:为混合和多云环境创建混合激活。按照以下流程指定激活代码和 ID。

SSM Agent在混合和多云环境中的非 EC2 Windows Server 计算机上安装
  1. 登录混合和多云环境中的服务器或虚拟机。

  2. 如果使用 HTTP 或 HTTPS 代理,则必须在当前 Shell 会话中设置 http_proxyhttps_proxy 环境变量。如果您不使用代理,则可跳过此步骤。

    对于 HTTP 代理服务器,请设置以下变量:

    http_proxy=http://hostname:port https_proxy=http://hostname:port

    对于 HTTPS 代理服务器,请设置以下变量:

    http_proxy=http://hostname:port https_proxy=https://hostname:port
  3. 在提升(管理)模式下打开 Windows PowerShell。

  4. 将以下命令块复制并粘贴到 Windows PowerShell 中。将每个示例资源占位符替换为您自己的信息。例如,在创建混合激活时生成的激活码和激活 ID,以及Amazon Web Services 区域您要SSM Agent从其下载的的标识符。

    region 表示 Amazon Systems Manager 支持的 Amazon Web Services 区域 的标识符,例如 us-east-2 对应美国东部(俄亥俄)区域。有关支持的区域值的列表,请参阅中的 S ystems Manager 服务端点中的 “区域” 列Amazon Web Services 一般参考

    64-bit
    $code = "activation-code" $id = "activation-id" $region = "region" $dir = $env:TEMP + "\ssm" New-Item -ItemType directory -Path $dir -Force cd $dir (New-Object System.Net.WebClient).DownloadFile("https://s3.cn-north-1.amazonaws.com.cn/amazon-ssm-cn-north-1/latest/windows_amd64/AmazonSSMAgentSetup.exe", $dir + "\AmazonSSMAgentSetup.exe") Start-Process .\AmazonSSMAgentSetup.exe -ArgumentList @("/q", "/log", "install.log", "CODE=$code", "ID=$id", "REGION=$region") -Wait Get-Content ($env:ProgramData + "\Amazon\SSM\InstanceData\registration") Get-Service -Name "AmazonSSMAgent"
    32-bit
    $code = "activation-code" $id = "activation-id" $region = "region" $dir = $env:TEMP + "\ssm" New-Item -ItemType directory -Path $dir -Force cd $dir (New-Object System.Net.WebClient).DownloadFile("https://s3.cn-north-1.amazonaws.com.cn/amazon-ssm-cn-north-1/latest/windows_386/AmazonSSMAgentSetup.exe", $dir + "\AmazonSSMAgentSetup.exe") Start-Process .\AmazonSSMAgentSetup.exe -ArgumentList @("/q", "/log", "install.log", "CODE=$code", "ID=$id", "REGION=$region") -Wait Get-Content ($env:ProgramData + "\Amazon\SSM\InstanceData\registration") Get-Service -Name "AmazonSSMAgent"
  5. Enter

此命令执行以下操作:

  • 下载并在计算机上安装 SSM Agent。

  • 向 Systems Manager 服务注册计算机。

  • 返回类似以下内容的请求响应:

        Directory: C:\Users\ADMINI~1\AppData\Local\Temp\2
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    d-----       07/07/2018   8:07 PM                ssm
    {"ManagedInstanceID":"mi-008d36be46EXAMPLE","Region":"us-east-2"}
    
    Status      : Running
    Name        : AmazonSSMAgent
    DisplayName : Amazon SSM Agent

该计算机现在已是托管节点了。现在,这些托管节点带有前缀“mi-”作为标识。您可以使用命令或使用 API Amazon CLI 命令describe-instance-information在中的Fleet Manager托管节点页面上查看托管节点DescribeInstanceInformation

设置私有密钥自动轮换

为了加强安保状况,您可以将 Amazon Systems Manager Agent (SSM Agent) 配置为自动轮换混合和多云环境私有密钥。您可以使用 SSM Agent 版本 3.0.1031.0 或更高版本来访问此功能。使用以下过程开启此功能。

配置SSM Agent为轮换混合和多云环境的私钥
  1. 在 Linux 计算机上导航到 /etc/amazon/ssm/,或者在 Windows Server 计算机上导航到 C:\Program Files\Amazon\SSM

  2. amazon-ssm-agent.json.template 的内容复制到名为 amazon-ssm-agent.json 的新文件中。Saveamazon-ssm-agent.json在同一目录中,其中amazon-ssm-agent.json.template位于中。

  3. 找到 ProfileKeyAutoRotateDays。输入您希望自动轮换私有密钥的间隔天数。

  4. 重启 SSM Agent。

每次更改配置时,请重新启动 SSM Agent。

您可以按照相同的过程自定义 SSM Agent 的其他功能。有关可用Config 属性及其默认值的up-to-date列表,请参阅配置属性定义

取消注册及重新注册托管节点

您可以通过从Amazon CLI或适用于 Windows PowerShell 的工具调用 DeregisterManagedInstanceAPI 操作来取消注册托管节点的。以下是一个示例 CLI 命令:

aws ssm deregister-managed-instance --instance-id "mi-1234567890"

您可以在取消注册计算机后重新注册该计算机。按照以下步骤来重新注册托管托管托管托管托管节点的计算机。完成这些步骤后,您的托管节点将再次在托管节点列表中显示。

在 Windows 混合计算机上重新注册托管节点
  1. Connect 您的机器。

  2. 运行以下命令。请务必将占位符值替换为在创建混合激活时生成的激活码和激活 ID,以及要SSM Agent从其下载的区域的标识符。

    'yes' | & 'C:\Program Files\Amazon\SSM\amazon-ssm-agent.exe' -register -code activation-code -id activation-id -region region; Restart-Service AmazonSSMAgent