# SSH & CMK Key 생성하기

## 1. SSH Key 생성하기

Cloud9에서 SSH 키를 생성하려면 아래 명령을 실행하세요. 필요한 경우 이 키는 작업자 노드 인스턴스에서 ssh 액세스를 허용하는 데 사용됩니다.

```
ssh-keygen
```

`Enter` 키를 세 차례 눌러 기본 옵션으로 키를 생성합니다. 공개 키를 사용중인 EC2 리전에 업로드합니다.

```
aws ec2 import-key-pair --key-name "eksworkshop" --public-key-material fileb://~/.ssh/id_rsa.pub

```

## 2. CMK 생성하기

쿠버네티스 secrets를 암호화 할 때 사용할 EKS 클러스터에 대한 CMK(사용자 관리 키)를 생성합니다.

```
aws kms create-alias --alias-name alias/eksworkshop --target-key-id $(aws kms create-key --query KeyMetadata.Arn --output text)
```

클러스터 생성 명령에 입력 할 CMK의 ARN을 검색해 보겠습니다. 나중에 KMS 키를 더 쉽게 참조 할 수 있도록 MASTER\_ARN 환경 변수를 설정 합니다.

```
export MASTER_ARN=$(aws kms describe-key --key-id alias/eksworkshop --query KeyMetadata.Arn --output text)
```

이제 MASTER\_ARN 환경 변수를 bash\_profile에 저장 하겠습니다.

```
echo "export MASTER_ARN=${MASTER_ARN}" | tee -a ~/.bash_profile
```

![](https://1998608250-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhByD5wv8eUbA5ZbUY5%2F-MhByH33eTdjfCd2bCjB%2F-MhCJYFydA_vtSl3olhm%2Fimage.png?alt=media\&token=f1033356-8338-4a5b-af9b-21187abd3676)

{% hint style="info" %}
[AWS KMS(Key Management Service)](https://aws.amazon.com/ko/kms/)를 사용하면 손쉽게 암호화 키를 생성 및 관리하고 다양한 AWS 서비스와 애플리케이션에서의 사용을 제어할 수 있습니다. AWS KMS는 FIPS 140-2에 따라 검증되었거나 검증 과정에 있는 하드웨어 보안 모듈을 사용하여 키를 보호하는 안전하고 복원력 있는 서비스입니다. 또한, AWS KMS는 AWS CloudTrail과도 통합되어 모든 키 사용에 관한 로그를 제공함으로써 각종 규제 및 규정 준수 요구 사항을 충족할 수 있게 지원합니다. EKS에서는 쿠버네티스와 Key를 통한 인증이 많이 일어납니다. 안전한 관리를 위해 Option으로 구성할 수 있습니다.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wjlee81.gitbook.io/amazon-eks/undefined/ssh-and-cmk-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
