AWS/ECS

[AWS ECS] How to create a Key Pair in ECS?

brightlightkim 2022. 3. 23. 03:39

Create a key pair

For Amazon ECS, a key pair is only needed if you intend on using the EC2 launch type.

AWS uses public-key cryptography to secure the login information for your instance. A Linux instance, such as an Amazon ECS container instance, has no password to use for SSH access. You use a key pair to log in to your instance securely. You specify the name of the key pair when you launch your container instance, then provide the private key when you log in using SSH.

If you haven't created a key pair already, you can create one using the Amazon EC2 console. If you plan to launch instances in multiple regions, you'll need to create a key pair in each region. For more information about regions, see Regions and Availability Zones in the Amazon EC2 User Guide for Linux Instances.

To create a key pair

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. From the navigation bar, select a Region for the key pair. You can select any Region that's available to you, regardless of your location. However, key pairs are specific to a Region. For example, if you plan to launch a container instance in the US East (Ohio) Region, you must create a key pair for the instance in the US East (Ohio) Region.
  3. In the navigation pane, under NETWORK & SECURITY, choose Key Pairs.
  4. Tip

    The navigation pane is on the left side of the console. If you do not see the pane, it might be minimized; choose the arrow to expand the pane. You may have to scroll down to see the Key Pairs link.

  5. Choose Create Key Pair.
  6. Enter a name for the new key pair in the Key pair name field of the Create Key Pair dialog box, and then choose Create. Use a name that is easy for you to remember, such as your IAM user name, followed by -key-pair, plus the region name. For example, me-key-pair-useast2.
  7. The private key file is automatically downloaded by your browser. The base file name is the name you specified as the name of your key pair, and the file name extension is .pem. Save the private key file in a safe place.
  8. Important

    This is the only chance for you to save the private key file. Provide the name of your key pair when you launch an instance and the corresponding private key each time you connect to the instance.

  9. If you use an SSH client on a macOS or Linux computer to connect to your Linux instance, use the following command to set the permissions of your private key file so that only you can read it.
  10.  
    chmod 400 your_user_name-key-pair-region_name.pem

For more information, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide for Linux Instances.

To connect to your instance using your key pair

To connect to your Linux instance from a computer running macOS or Linux, specify the .pem file to your SSH client with the -i option and the path to your private key. To connect to your Linux instance from a computer running Windows, you can use either MindTerm or PuTTY. If you plan to use PuTTY, you need to install it and use the following procedure to convert the .pem file to a .ppk file.

To prepare to connect to a Linux instance from Windows using PuTTY

  1. Download and install PuTTY from http://www.chiark.greenend.org.uk/~sgtatham/putty/. Be sure to install the entire suite.
  2. Start PuTTYgen (for example, from the Start menu, choose All Programs > PuTTY > PuTTYgen).
  3. Under Type of key to generate, choose RSA.
  4. Choose Load. By default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, select the option to display files of all types.
  5. Select the private key file that you created in the previous procedure and choose Open. Choose OK to dismiss the confirmation dialog box.
  6. Choose Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes.
  7. Specify the same name for the key that you used for the key pair. PuTTY automatically adds the .ppk file extension.

'AWS > ECS' 카테고리의 다른 글

[Amazon ECS] Using the awslogs log driver  (0) 2022.05.05
[AWS ECS] How to Create a Security Group?  (0) 2022.03.23
[AWS ECS] How to Create an IAM user  (0) 2022.03.23
[AWS ECS] Create AWS IAM  (0) 2022.03.22
[AWS ECS] Amazon ECS Basics  (0) 2022.03.22