Skip to main content

공유 AMI로부터 가상 머신 시작하기

This workshop워크샵 section섹션에서는 walks워크샵의 you뒷부분에서 through분석을 setting실행하는 up your사용할 own사전 제작된 AMI에서 자체 EC2 Linux instance인스턴스를 from설정하는 a방법을 premade AMI, which you will use to run analyses in later sections of the workshop.안내합니다.

We’ll여기서는 beNUS와 using an image built by theGIS의 Chen LabLab에서 at구축한 NUS이미지를 and사용할 GIS.것입니다. This여기에는 has박테리아(및 a일반) lot유전체학에 of유용한 common많은 tools공통 useful도구가 for설치되어 bacterial있습니다. (and general) genomics installed. We have documented whatAMI에 is무엇이 on있고 this어떻게 AMI설정되었는지는 and함께 how it was set up on our제공되는 accompanying GitHub repository리포지토리에 문서화되어 있습니다. Those이러한 instructions지침은 may다른 be시스템에서 useful동일한 if소프트웨어를 you설정하려는 want경우 to유용할 set up있으며, the자신의 same작업을 software위해 on다른 another소프트웨어를 system설치할 and may help가지 you힌트를 with얻을 some hints when installing other software as well for your own work.있습니다.

Specifically,구체적으로 you다음과 learn같은 how방법을 to:배웁니다:

a. Sign in to the AWS Management관리 Console콘솔에 and로그인하여 explore it.탐색합니다.

b. Create anAMI에서 Amazon EC2 instance인스턴스를 from an AMI.생성합니다.

c. SSH into an EC2 instance인스턴스에 andSSH로 run접속하여 Linux commands.명령을 실행합니다.

Launch the

EC2 Dashboard

대시보드 시작
  1. In the AWS Management관리 Console콘솔 search검색 bar, type창에 EC2를 입력합니다.

     

  2. Choose EC2 to open the선택하여 EC2 Dashboard를 엽니다.

Spend대시보드의 a레이아웃에 few익숙해지는 minutes familiarizing yourself with정도 the시간을 layout of the dashboard:할애하세요:

  • Left왼쪽 pane:창: Tools and features, such as the saved저장된 Amazon Machine머신 Images 이미지(AMIs)AMI), storage스토리지 volumes,볼륨 and ssh keys.키와 같은 도구 및 기능입니다.
  • Center:가운데: Resource리소스 listings목록 and the인스턴스 ability시작 to launch an instance.기능.
  • Right오른쪽 pane:창: General문서 information, such가격 as등의 documentation일반 and pricing.정보.

Screenshot 2023-09-26 at 11.36.10 PM.pngScreenshot 2023-09-26 at 11.36.10 PM.png

Launch

EC2 an인스턴스 시작

이제 EC2 InstanceLinux

We기반 will인스턴스를 now launch an EC2 Linux-based instance.시작하겠습니다.

  1. Click on Launch Instance , then클릭한 click다음 드롭다운 메뉴에서 Launch instanceInstance again다시 from the drop down menu.클릭합니다.

Screenshot 2023-09-26 at 11.36.35 PM.pngScreenshot 2023-09-26 at 11.36.35 PM.png

  1. On the Launch an instance page,페이지에서 you인스턴스의 can원하는 choose이름을 a지정할 friendly name있습니다. for your instance.

Screenshot 2023-09-26 at 11.37.10 PM.pngScreenshot 2023-09-26 at 11.37.10 PM.png

  1. Click on Add additional tags and 클릭하고 "Add Tag”Tag"를 클릭합니다. You인스턴스에 will대해 find제공한 the"Name"을 “Name”찾을 you provided있습니다. for이제 your키와 instance.값을 Now입력합니다. enter the키(더 key정확하게는 and태그)는 value.인스턴스가 These시작되면 keys,콘솔에 more나타납니다. correctly이를 known통해 as복잡한 a환경에서 tags,실행 will중인 appear머신을 in쉽게 the추적할 console once있습니다. the이전에 instance launches.쌍에 It사용한 makes것과 it유사한 easy태그를 to추가로 keep생성하여 track of머신에 running사용자와 machines부여 in키를 a지정하고 complex동일한 environment.값을 Create입력합니다. additional준비가 tags similar for the ones you used for the key pair previously - give a user and grant key to this machine, and enter the same values. When ready, select Instances, Volumes, Network interfaces under the되면 Resource types 아래에서 Instances, Volumes, Network interfaces 선택합니다. 

Screenshot 2023-09-26 at 11.37.56 PM.pngScreenshot 2023-10-07 at 12.03.29 AM.png

  1. Under Application and OS images (Amazon Machine Image) 아래에서 enter검색 the상자에 교육용으로 공유된 AMI IDID를 shared for the training into the search box. The입력합니다. AMI may사진과 differ다를 from the있으므로 one강사의 pictured;안내를 refer참조하세요. to instructor’s directions.

Note:

For this교육을 training, search for위해 CHENLAB-PUBLIC and검색하여 choose가장 the most recent최신 AMI version;버전(2022년 as9월 of September, 2022 this is v2.10b, which has기준, ID ami-0d36350156cb783e8인 v2.10b)을 선택하시기 바랍니다. You can find out more about CHENLAB-PUBLIC AMIs in Appendix: About the AMI.

Screenshot 2023-09-27 at 10.06.49 AM.pngScreenshot 2023-09-27 at 10.06.49 AM.png

  1. Community AMIs에서 결과를 클릭합니다.

    The검색 results of the search appear결과는 in Community AMIs and표시됩니다. in AWS Marketplace.

    Screenshot 2023-09-27 at 10.07.50 AM.pngScreenshot 2023-09-27 at 10.07.50 AM.png

    1. Click on the results in Community AMIs.

    The AMI ID will now appear.

    1. Click on the Select button to select the AMI. Be sure to select the lastest version of the AMI (see above, Step 4. Note).

    2. UnderSelect 버튼을 클릭하여 AMI를 선택합니다. 최신 버전의 AMI를 선택해야 합니다(위 4단계 참고 참조).

    3. Instance type,에서 click드롭다운 on화살표를 the클릭하고 drop-down arrow and type검색창에 t3a.mediumc5.4xlarge into입력합니다. the
      search bar.

      Screenshot 2023-09-27 at 10.08.43 AM.pngScreenshot 2023-10-07 at 12.08.34 AM.png

    1. Select the key pair that you created in the beginning of this lab from the drop-down list under Key pair (login) 아래의 드롭다운 목록에서 이 실습의 시작 부분에서 만든 키 쌍을 선택합니다. 

      Screenshot 2023-09-27 at 10.08.50 AM.png

    1. Next click on Edit against다음으로 Network settings에 대해 Edit을 클릭합니다. You will be prompted to provide Subnet and Security group details.세부 The정보를 security입력하라는 groups메시지가 will be your firewall rules.
          a. Note that the Subnet field can be configured to launch the instance in a specific Availability Zone; while we are keeping the default for this workshop, this gives you control over the location of your machine.
          b. Provide a name for your new security group. NOTE: For the purpose of this lab use your “[Your initials]-sec-group”.
          c. Confirm an existing SSH rule exists which allows TCP port 22.
          d. To accept connections from anywhere, select the drop-down box under the Source type column and select Anywhere which will correspond to 0.0.0.0/0.

    특별히 네트워크 설정 수정할 것은 없습표시됩니다. 앞에서 launch-wizard-1으로 새로운 보안 그룹이 만들어졌다면 이제 +1증가해서 자동으로 launch-wizard-2라는 보안 그룹 이름이 부여된다는 점을 확인해주세요. 보안 그룹 launch-wizard-1이방화벽 만들어져규칙이 있다면 새로 만들지 않고 이것으로 설정해도 무방합니다. (앞 챕터에서 진행했다면 만들어진 보안 그룹 설정사용할 내용이수도 동일하므로)있습니다.
       

    Screenshot 2023-10-07 at 12.10.00 AM.png


    1. Under Configure storage, you have the ability to modify or add storage and disk drives to the instance. For this lab, we will simply accept the storage defaults.

      Screenshot 2023-09-27 at 10.10.08 AM.png

    1. Review your configuration under Summary and click Launch Instance.

    Screenshot 2023-09-27 at 10.12.01 AM.png

    Your instance will now start, which may take a moment. You will be shown the Launch Status page with the message Successfully initiated launch of instance.

    1. On the lower right of the page click on View all Instances to view the list of EC2 instances. Click on your instance. It will go through an initialization process. Once your instance has launched, you will see your Linux server as well as the Availability Zone the instance is in, and the publicly routable DNS name.

    Screenshot 2023-09-27 at 10.17.42 AM.png

    SSH into an EC2 instance

    The operating system of your local computer determines the options that you have to connect from your local computer to your Linux instance. Here are directions to connect from Windows Using PuTTY or OpenSSH, From Linux & MacOS-X using ssh client and from Windows Subsystem for Linux (WSL) using ssh client.

    Note: The premade CHENLAB-PUBLIC AMI is Ubuntu, so your username will be “ubuntu”

    Connecting from Windows using PuTTY

    We will now use the private .ppk file of the key pair generated earlier to open a SSH session to the EC2 instance.

    1. Start the PuTTy application.

    2. Enter in the IP address of the EC2 instance in the Host Name (or IP address) field.

    3. To save the session (so we dont have to repeat the configuration everytime) provide a name in the Saved Sessions field.

    4. In the left navigation pane under Connections clickon SSH and next click on Auth.

    5. In the Private key file for authentication field click Browse and browse in the .ppk file downloaded when creating the key pair earlier.

    6. Next in the left navgation pane click on Session (scroll up if you need to) and and further click on Save to save the session.

    7. Next click on Open to start the SSH session.

    8. PuTTy will now attempt to start an SSH Session.

    NOTE: You will get a security Alert The Servers host key is not cached in the registry, click on Yes to continue.

    1. You will now be presented with the login as prompt.

    2. At the login as prompt type ec2-user if your image is Amazon Linux OS or ubuntu if your image is Ubuntu Linux OS and hit enter.

    You would have now logged into the EC2 instance on AWS.


    Connecting from Windows using MobaXterm

    We will use the private .pem key pair to open an SSH session to the EC2 instance.

    1. Start the MobaXterm application.

    2. To open a session, click on Session in the top-left corner, then click SSH.

    3. Enter in the IP address of the EC2 instance in the Host Name field.

    4. To the right, select username and enter your username for the session.

    NOTE: Username to be used here is ec2-user if your image is Amazon Linux OS and ubuntu if your image is Ubuntu Linux OS.

    1. Below, click on Advanced Settings, and select private key (use your .pem file).

    2. Click Ok.

    MobaXterm will have logged you in to your EC2 instance.


    Connecting from Windows using Windows Subsystem for Linux

    We will now use the private .pem file of the key pair generated earlier to open a SSH session to the EC2 instance.

    1. Copy the private key from Windows to WSL - In a WSL terminal window, copy the .pem file (for the key pair that you specified when you launched the instance) from Windows to WSL. Note the fully-qualified path to the .pem file on WSL to use when connecting to your instance.
    cp /mnt/<Windows drive letter>/path/my-key-pair.pem ~/WSL-path/my-key-pair.pem
    
    1. In a terminal window, use the ssh command to connect to the instance. You specify the path and file name of the private key (.pem), the user name for your instance, and the public DNS name or IP Address.

    NOTE: Username to be used here is ec2-user if your image is Amazon Linux OS and ubuntu if your image is Ubuntu Linux OS.

    sudo ssh -i /path/my-key-pair.pem ubuntu@<ip-address>
    

    you will see the following response

    The authenticity of host '<ip-address>'
    can't be established.
    RSA key fingerprint is 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f.
    Are you sure you want to continue connecting (yes/no)?
    
    1. Enter Yes

    you will now be logged into the EC2 Instance.


    Connecting using SSH on Linux & MacOS and OpenSSH on Windows

    We will now use the private .pem file of the key pair generated earlier to open a SSH session to the EC2 instance.

    1. In a terminal window, use the ssh command to connect to the instance. You specify the path and file name of the private key (.pem), the user name for your instance, and the public DNS name or IP Address of your instance.

    NOTE: Username to be used here is ubuntu if your image is based on the Ubuntu Linux OS and ec2-user if your image is based on Amazon Linux OS. (See this page which covers many of the common AMI OSs.)

    ssh -i /path/my-key-pair.pem ubuntu@<ip-address>
    

    You see a response like the following:

    The authenticity of host 'ec2-198-51-100-1.compute-1.amazonaws.com (198-51-100-1)' can't be established.
    ECDSA key fingerprint is l4UB/neBad9tvkgJf1QZWxheQmR59WgrgzEimCG6kZY.
    Are you sure you want to continue connecting (yes/no)?
    
    1. Enter Yes

    You will now be logged into the Instance.

    NOTE: you might need to change the permissions of the key file by running the chmod command as follows. Edit to match your path and key pair name.

    sudo chmod 600 /path/my-key-pair.pem
    

    For detailed directions on these please have a look at the following links:

    PuTTY, Windows Susbsystem for Linux, MacOS-X ssh Client, Linux ssh client

    예)

    Screenshot 2023-09-27 at 10.15.46 AM.png