1
0
mirror of synced 2024-11-24 22:06:07 +03:00

- update documentation

This commit is contained in:
Scottpedia 2023-09-23 13:25:25 -04:00
parent 8dec67a959
commit 46cebd031e
3 changed files with 25 additions and 13 deletions

View File

@ -80,9 +80,11 @@ EC2 上的每个 Linux 服务器发行版本都有它自己的默认登录用户
| CentOS (`CentOS 7`) | `centos` | | CentOS (`CentOS 7`) | `centos` |
| Amazon Linux 2 | `ec2-user` | | Amazon Linux 2 | `ec2-user` |
此模板在部署期间为你生成一个密钥对,并且在成功创建堆栈后,按照以下步骤来提取私钥。 此模板在部署期间为你生成一个密钥对。在成功创建堆栈后,你可以使用以下的其中一种方式来获取私钥。
**Outputs** 页面拷贝私钥对 ID ,然后使用以下命令来提取私钥内容,并且将其保存到一个证书文件中。 1. 在 **Outputs** 页面下拷贝密钥对 ID ,然后使用以下命令来提取私钥内容并且将其保存为一个证书文件:
> **注:** 在使用以下命令前,你需要在你的电脑上正确的安装和配置好 AWS 命令行。更多关于开始使用 AWS 命令行的信息,请参照 [Get started with the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) 。
``` ```
$ aws ssm get-parameter --region your-region --name /ec2/keypair/your-key-pair-id --with-decryption --query Parameter.Value --output text > new-key-pair.pem $ aws ssm get-parameter --region your-region --name /ec2/keypair/your-key-pair-id --with-decryption --query Parameter.Value --output text > new-key-pair.pem
@ -90,6 +92,10 @@ $ aws ssm get-parameter --region your-region --name /ec2/keypair/your-key-pair-i
![显示密钥 ID](images/show-key-id.png) ![显示密钥 ID](images/show-key-id.png)
2. 直接从 **Outputs** 页面拷贝私钥对内容 ,然后将其保存入一个证书文件。请注意在保存到你的计算机之前,你可能需要修改私钥的格式,比如用换行符替换所有的空格。在保存后,需要为该私钥文件设置[适当的权限](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-private-key)才能使用。
![显示密钥内容](images/show-key-id.png)
要为私钥文件设置适当的权限,请在该文件所在的目录下运行以下命令: 要为私钥文件设置适当的权限,请在该文件所在的目录下运行以下命令:
```bash ```bash
$ sudo chmod 400 new-key-file.pem $ sudo chmod 400 new-key-file.pem
@ -97,7 +103,7 @@ $ sudo chmod 400 new-key-file.pem
使用 SSH 登录到 EC2 实例的示例命令: 使用 SSH 登录到 EC2 实例的示例命令:
```bash ```bash
$ ssh -i path/to/your/key-file.pem instance-username@instance-ip-address $ ssh -i path/to/your/new-key-file.pem instance-username@instance-ip-address
``` ```
</details> </details>

View File

@ -80,16 +80,22 @@ List of default usernames:
| CentOS (`CentOS 7`) | `centos` | | CentOS (`CentOS 7`) | `centos` |
| Amazon Linux 2 | `ec2-user` | | Amazon Linux 2 | `ec2-user` |
This template generates a key pair for you during deployment, and to acquire the private key you need to follow the following procedures. This template generates a key pair for you during deployment, and to acquire the private key you can choose one of the following two methods.
Copy the key pair ID displayed under the **Outputs** tab, and use the following command to retrieve the private key material and save it into a certificate file: 1. Copy the key pair ID displayed under the **Outputs** tab, and use the following command to retrieve the private key material and save it into a certificate file:
> **Note:** You need to first properly set up the AWS CLI on your computer before using the following command. For more information on how to get started with AWS CLI, please refer to [Get started with the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html).
``` ```
$ aws ssm get-parameter --region your-region --name /ec2/keypair/your-key-pair-id --with-decryption --query Parameter.Value --output text > new-key-pair.pem $ aws ssm get-parameter --region your-region --name /ec2/keypair/your-key-pair-id --with-decryption --query Parameter.Value --output text > new-key-file.pem
``` ```
![Show key ID](images/show-key-id.png) ![Show key ID](images/show-key-id.png)
2. Copy the private key material directly from the **Outputs** tab, and save it into a certificate file. Note that You may need to format the private key by replacing all spaces with newlines, before saving to a file. The file will need to be set with [proper permissions](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-private-key) before using.
![Show key material](images/show-key.png)
To apply proper permissions to your private key file, run the following command under the directory where the file is located: To apply proper permissions to your private key file, run the following command under the directory where the file is located:
```bash ```bash
$ sudo chmod 400 new-key-file.pem $ sudo chmod 400 new-key-file.pem

BIN
aws/images/show-key.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB