

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

# 安全隧道
<a name="secure-tunneling-component"></a>

借助 `aws.greengrass.SecureTunneling` 组件，您可以与位于受限防火墙后面的 Greengrass 核心设备建立安全的双向通信。

例如，假设您的 Greengrass 核心设备位于防火墙后面，防火墙禁止所有传入连接。安全隧道使用 MQTT 将访问令牌传输到设备，然后使用 WebSockets 通过防火墙与设备建立 SSH 连接。使用此 AWS IoT 管理的隧道，您可以打开设备所需的 SSH 连接。*有关使用 AWS IoT 安全隧道连接远程设备的更多信息，请参阅《开发人员指南》中的[AWS IoT 安全隧道](https://docs.aws.amazon.com/iot/latest/developerguide/secure-tunneling.html)。AWS IoT *

此组件订阅`$aws/things/greengrass-core-device/tunnels/notify`主题上的 AWS IoT Core MQTT 消息代理以接收安全隧道通知。

**Topics**
+ [版本](#secure-tunneling-component-versions)
+ [Type](#secure-tunneling-component-type)
+ [操作系统](#secure-tunneling-component-os-support)
+ [要求](#secure-tunneling-component-requirements)
+ [依赖项](#secure-tunneling-component-dependencies)
+ [配置](#secure-tunneling-component-configuration)
+ [本地日志文件](#secure-tunneling-component-log-file)
+ [许可证](#secure-tunneling-component-licenses)
+ [用法](#secure-tunneling-component-usage)
+ [另请参阅](#secure-tunneling-component-see-also)
+ [更改日志](#secure-tunneling-component-changelog)

## 版本
<a name="secure-tunneling-component-versions"></a>

此组件具有以下版本：
+ 2.0.x
+ 1.1.x
+ 1.0.x

## Type
<a name="secure-tunneling-component-type"></a>

<a name="public-component-type-generic"></a>此<a name="public-component-type-generic-phrase"></a>组件是一个通用组件 (`aws.greengrass.generic`)。[Greengrass Nucleus](greengrass-nucleus-component.md) 运行组件的生命周期脚本。

<a name="public-component-type-more-information"></a>有关更多信息，请参阅[组件类型](develop-greengrass-components.md#component-types)。

## 操作系统
<a name="secure-tunneling-component-os-support"></a>

此组件只能安装在 Linux 核心设备上。

架构：
+ Armv71
+ Armv8 () AArch64
+ x86\$164

## 要求
<a name="secure-tunneling-component-requirements"></a>

此组件具有以下要求：

------
#### [ 2.0.x ]
+ 安全隧道组件至少有 4 MB 的可用磁盘空间。此要求不包括运行在同一设备上的 Greengrass 核心软件或其它组件。
+ 至少 3 MB RAM 可用于安全隧道组件。此要求不包括运行在同一设备上的 Greengrass 核心软件或其它组件。
+ GNU C 库 (glibc) 版本 2.35 或更高版本。不支持超过长期支持终止使用日期的操作系统和库的版本。您应该使用具有长期支持的操作系统和库。
+ Greengrass 核心设备上安装了以下运行时库：
  + `libstdc++`版本 3.4.29 或更高版本
  + `libgcc_s`3.0 或更高版本
  + OpenSSL 版本 3.0.0 或更高版本
+ 打开 Greengrass 核心设备 443 端口的出站流量。
+ 开启对用以与 Greengrass 核心设备通信的通信服务的支持。例如，要打开与设备的 SSH 连接，则必须在该设备上打开 SSH。

------
#### [ 1.0.x - 1.1.x ]
+ 安全隧道组件的可用磁盘空间不得低于 32 MB。此要求不包括运行在同一设备上的 Greengrass 核心软件或其它组件。
+ 安全隧道组件至少需要 16 MB 的可用内存。此要求不包括运行在同一设备上的 Greengrass 核心软件或其它组件。有关更多信息，请参阅 [使用 JVM 选项控制内存分配](configure-greengrass-core-v2.md#jvm-tuning)。
+ 安全隧道组件版本 1.0.12 及更高版本要求 GNU C 库（glibc）版本 2.25 或更高版本以及 Linux 内核 3.2 或更高版本。不支持超过长期支持终止使用日期的操作系统和库的版本。您应该使用具有长期支持的操作系统和库。
+ 操作系统和 Java 运行时都必须安装为 64 位。
+ [Python](https://www.python.org/) 3.5 或更高版本已安装在 Greengrass 核心设备上，并已添加到 PATH 环境变量中。
+ `libcrypto.so.1.1` 已安装在 Greengrass 核心设备上并已添加到 PATH 环境变量中。
+ 打开 Greengrass 核心设备 443 端口的出站流量。
+ 开启对用以与 Greengrass 核心设备通信的通信服务的支持。例如，要打开与设备的 SSH 连接，则必须在该设备上打开 SSH。

------

### 端点和端口
<a name="secure-tunneling-component-endpoints"></a>

除了基本操作所需的端点和端口外，此组件还必须能够对以下端点和端口执行出站请求。有关更多信息，请参阅 [允许设备流量通过代理或防火墙](allow-device-traffic.md)。


| 端点 | 端口： | 必需 | 说明 | 
| --- | --- | --- | --- | 
|  `data.tunneling.iot.region.amazonaws.com`  | 443 | 是 |  建立安全隧道。  | 

## 依赖项
<a name="secure-tunneling-component-dependencies"></a>

部署组件时， AWS IoT Greengrass 还会部署其依赖项的兼容版本。这意味着您必须满足组件及其所有依赖关系的要求，才能成功部署组件。本部分列出了此组件的[已发布版本](#secure-tunneling-component-changelog)的依赖关系，以及定义每个依赖关系的组件版本的语义版本约束。您还可以在 [AWS IoT Greengrass 控制台](https://console.aws.amazon.com//greengrass)中查看每个组件版本的依赖关系。在组件详细信息页面上，查找**依赖关系**列表。

------
#### [ 2.0.0 ]

该组件的 2.0.0 版本同时支持 Greengrass nucleus 和 Greengrass nucleus lite。下表列出了此组件版本 2.0.0 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [[Greengrass nucleus or Greengrass nucleus lite](greengrass-nucleus-lite-component.md)](greengrass-nucleus-component.md) |  >=2.0.0 <3.0.0  | 软性 | 

------
#### [ 1.0.19 – 1.1.3 ]

下表列出了此组件的 1.0.19 到 1.1.3 版本的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <3.0.0  | 软性 | 

------
#### [ 1.0.18 ]

下表列出了此组件版本 1.0.18 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.13.0  | 软性 | 

------
#### [ 1.0.16 – 1.0.17 ]

下表列出了此组件版本 1.0.16 至 1.0.17 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.12.0  | 软性 | 

------
#### [ 1.0.14 – 1.0.15 ]

下表列出了此组件版本 1.0.14 至 1.0.15 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.11.0  | 软性 | 

------
#### [ 1.0.11 – 1.0.13 ]

下表列出了此组件版本 1.0.11 至 1.0.13 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.10.0  | 软性 | 

------
#### [ 1.0.10 ]

下表列出了此组件版本 1.0.10 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.9.0  | 软性 | 

------
#### [ 1.0.9 ]

下表列出了此组件版本 1.0.9 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.8.0  | 软性 | 

------
#### [ 1.0.8 ]

下表列出了此组件版本 1.0.8 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.7.0  | 软性 | 

------
#### [ 1.0.5 - 1.0.7 ]

下表列出了此组件版本 1.0.5 到 1.0.7 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.6.0  | 软性 | 

------
#### [ 1.0.4 ]

下表列出了此组件的版本 1.0.4 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.5.0  | 软性 | 

------
#### [ 1.0.3 ]

下表列出了此组件版本 1.0.3 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.4.0  | 软性 | 

------
#### [ 1.0.2 ]

下表列出了此组件版本 1.0.2 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.3.0  | 软性 | 

------
#### [ 1.0.1 ]

下表列出了此组件版本 1.0.1 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.0 <2.2.0  | 软性 | 

------
#### [ 1.0.0 ]

下表列出了此组件的版本 1.0.0 的依赖关系。


| 依赖关系 | 兼容版本 | 依赖关系类型 | 
| --- | --- | --- | 
| [Greengrass Nucleus](greengrass-nucleus-component.md) |  >=2.0.3 <2.1.0  | 软性 | 

------

有关组件依赖关系的更多信息，请参阅[组件配方参考](component-recipe-reference.md#recipe-reference-component-dependencies)。

## 配置
<a name="secure-tunneling-component-configuration"></a>

此组件提供您可以在部署组件时自定义的以下配置参数。

------
#### [ 2.0.x ]

`maxConcurrentTunnels`  
（可选）允许的最大并发隧道数。  
该值不能超过 20。
默认值：`20`

`tunnelTimeoutSeconds`  
（可选）隧道超时持续时间（以秒为单位）。  
默认：`43200`（12 小时）

`accessControl`  
（可选）包含允许组件订阅安全隧道通知主题的[授权策略](interprocess-communication.md#ipc-authorization-policies)的对象。  
如果您的部署以事物组为目标，请勿修改此配置参数。如果您的部署以单个核心设备为目标，并且您想将其订阅限制为该设备的主题，请指定核心设备的事物名称。在设备授权策略的 `resources` 值中，将 MQTT 主题通配符替换为设备的事物名称。

```
{
  "aws.greengrass.ipc.mqttproxy": {
    "aws.greengrass.SecureTunneling:mqttproxy:1": {
      "policyDescription": "Access to tunnel notification pubsub topic",
      "operations": [
        "aws.greengrass#SubscribeToIoTCore"
      ],
      "resources": [
        "$aws/things/+/tunnels/notify"
      ]
    }
  }
}
```

**Example 示例：配置合并更新**  
以下示例配置指定了最大并发隧道数和超时设置。  

```
{
  "maxConcurrentTunnels": 20,
  "tunnelTimeoutSeconds": 43200,
  "accessControl": {
    "aws.greengrass.ipc.mqttproxy": {
      "aws.greengrass.SecureTunneling:mqttproxy:1": {
        "policyDescription": "Access to tunnel notification pubsub topic",
        "operations": [
          "aws.greengrass#SubscribeToIoTCore"
        ],
        "resources": [
          "$aws/things/MyGreengrassCore/tunnels/notify"
        ]
      }
    }
  }
}
```

------
#### [ 1.0.x - 1.1.x ]

`OS_DIST_INFO`  
（可选）核心设备的操作系统。默认情况下，该组件会尝试自动识别核心设备上运行的操作系统。如果组件无法使用默认值启动，请使用此值来指定操作系统。有关此组件支持的操作系统类型的完整列表，请参阅[设备要求](greengrass-nucleus-component.md#greengrass-v2-requirements)。  
它可以是以下值之一：`auto`、`ubuntu`、`amzn2`、`raspberrypi`。  
默认值：`auto`

`accessControl`  
（可选）包含允许组件订阅安全隧道通知主题的[授权策略](interprocess-communication.md#ipc-authorization-policies)的对象。  
如果您的部署以事物组为目标，请勿修改此配置参数。如果您的部署以单个核心设备为目标，并且您想将其订阅限制为该设备的主题，请指定核心设备的事物名称。在设备授权策略的 `resources` 值中，将 MQTT 主题通配符替换为设备的事物名称。

```
{
  "aws.greengrass.ipc.mqttproxy": {
    "aws.iot.SecureTunneling:mqttproxy:1": {
      "policyDescription": "Access to tunnel notification pubsub topic",
      "operations": [
        "aws.greengrass#SubscribeToIoTCore"
      ],
      "resources": [
        "$aws/things/+/tunnels/notify"
      ]
    }
  }
}
```

**Example 示例：配置合并更新**  
以下示例配置指定允许此组件在运行 Ubuntu 的名为 **MyGreengrassCore** 的核心设备上打开安全隧道。  

```
{
  "OS_DIST_INFO": "ubuntu",
  "accessControl": {
    "aws.greengrass.ipc.mqttproxy": {
      "aws.iot.SecureTunneling:mqttproxy:1": {
        "policyDescription": "Access to tunnel notification pubsub topic",
        "operations": [
          "aws.greengrass#SubscribeToIoTCore"
        ],
        "resources": [
          "$aws/things/MyGreengrassCore/tunnels/notify"
        ]
      }
    }
  }
}
```

------

## 本地日志文件
<a name="secure-tunneling-component-log-file"></a>

------
#### [ Greengrass nucleus ]

此组件使用以下日志文件。

```
/greengrass/v2/logs/aws.greengrass.SecureTunneling.log
```

**查看此组件的日志**
+ 在核心设备上运行以下命令可实时查看此组件的日志文件。`/greengrass/v2`替换为 AWS IoT Greengrass 根文件夹的路径。

  ```
  sudo tail -f /greengrass/v2/logs/aws.greengrass.SecureTunneling.log
  ```

------
#### [ Greengrass nucleus lite ]

在核心设备上运行以下命令以查看此组件的日志。

```
journalctl -xeau ggl.aws.greengrass.SecureTunneling.service
```

在核心设备上运行以下命令以实时查看此组件的日志。

```
journalctl -fau ggl.aws.greengrass.SecureTunneling.service
```

------

## 许可证
<a name="secure-tunneling-component-licenses"></a>

此组件包含以下第三方软件/许可：

------
#### [ 2.0.x ]
+ [AWS IoT 安全隧道本地代理](https://github.com/aws-samples/aws-iot-securetunneling-localproxy) /Apache 许可证 2.0
+ [AWS Greengrass 组件 SDK /Apache License 2.0](https://github.com/aws-greengrass/aws-greengrass-component-sdk)
+ [Boost C\$1\$1 库](https://www.boost.org/) /Boost 软件许可证 1.
+ [协议缓冲区](https://github.com/protocolbuffers/protobuf) /BSD 三条款许可证

------
#### [ 1.0.x - 1.1.x ]
+ [AWS IoT 设备客户端](https://github.com/awslabs/aws-iot-device-client) /Apache 许可证 2.0
+ [AWS IoT Device SDK for Java](https://github.com/aws/aws-greengrass-core-sdk-java/)/Apache 许可证 2.0
+ [gson](https://github.com/google/gson)/Apache 许可证 2.0
+ [log4j](https://logging.apache.org/log4j/2.x/)/Apache 许可证 2.0
+ [slf4j](http://www.slf4j.org/)/Apache 许可证 2.0

------

## 用法
<a name="secure-tunneling-component-usage"></a>

要在设备上使用安全隧道组件，请执行以下操作：

1. 将安全隧道组件部署到您的设备上。

1. 打开 [AWS IoT 控制台](https://console.aws.amazon.com/iot)。从左侧菜单中选择**远程操作**，然后选择**安全隧道**。

1. 创建一个连接 Greengrass 设备的隧道。

1. 下载源访问令牌。

1. 使用带有源访问令牌的本地代理连接到您的目标。有关更多信息，请参阅《AWS IoT 开发人员指南》**中的[如何使用本地代理](https://docs.aws.amazon.com/iot/latest/developerguide/how-use-local-proxy.html)。

## 另请参阅
<a name="secure-tunneling-component-see-also"></a>
+ AWS IoT *《开发人员指南》AWS IoT 中的@@ [安全隧道](https://docs.aws.amazon.com/iot/latest/developerguide/secure-tunneling.html)*
+ 《AWS IoT 开发人员指南》**中的[如何使用本地代理](https://docs.aws.amazon.com/iot/latest/developerguide/how-use-local-proxy.html)

## 更改日志
<a name="secure-tunneling-component-changelog"></a>

下表介绍每个组件版本的更改。


|  **版本**  |  **更改**  | 
| --- | --- | 
|  2.0.0  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.1.3  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.1.2  |   此版本不再可用。此版本的改进将在此组件的更高版本中提供。  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.1.1  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.1.0  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.0.19  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  如果您使用安全隧道本地代理作为隧道源客户端，将本地代理升级到版本 3.1.1 或更高版本之后，才能将组件更新到此版本。   | 
|  1.0.18  | 版本更新为 Greengrass Nucleus 版本 2.12.0 发布版。 | 
|  1.0.17  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.0.16  | 版本更新为 Greengrass Nucleus 版本 2.11.0 发布版。 | 
|  2016-09-01  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.0.14  | 版本更新为 Greengrass Nucleus 版本 2.10.0 发布版。 | 
|  1.0.13  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.0.12  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  2016-09-01  | 对 Greengrass Nucleus版本 2.9.0 发行版进行了版本更新。 | 
|  2016-09-01  | 版本更新为 Greengrass Nucleus 版本 2.8.0 发布版。 | 
|  1.0.9  |  版本更新为 Greengrass Nucleus 版本 2.7.0 发布版。  | 
|  1.0.8  |  版本更新为 Greengrass Nucleus 版本 2.6.0 发布版。  | 
|  1.0.7  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/greengrass/v2/developerguide/secure-tunneling-component.html)  | 
|  1.0.6  |  此版本包含错误修复。  | 
|  1.0.5  |  版本更新为 Greengrass Nucleus 版本 2.5.0 发布版。  | 
|  1.0.4  |  版本更新为 Greengrass Nucleus 版本 2.4.0 发布版。  | 
|  1.0.3  |  版本更新为 Greengrass Nucleus 版本 2.3.0 发布版。  | 
|  1.0.2  |  对 Greengrass Nucleus 版本 2.2.0 发行版进行了版本更新。  | 
|  1.0.1  |  对 Greengrass Nucleus 版本 2.1.0 发行版进行了版本更新。  | 
|  1.0.0  |  初始版本。  | 