DEV Community

loading...
Cover image for EC2 Instance: From Launching to Connecting Via SSH

EC2 Instance: From Launching to Connecting Via SSH

Reishi Mitani
Undergrad senior at University of Tokyo, Japan Working on web development, machine learning and IoT systems.
Updated on ・1 min read

Today I want to cover the process from launching an EC2 instance to connecting via SSH.

First, we will have to create the instance.
I selected the Linux Image at the top.

Alt Text

Continue clicking to the last page, right before launching. Before launching, you will be asked to make a key pair.
Choose Create a new key pair, as shown below, and download the pem file.

Alt Text

Inside the directory where the pem file exists, type the following command. Only the owner will be able to read the file now.

$ chmod 400 example-key-pair.pem
Enter fullscreen mode Exit fullscreen mode

Now we are ready to go with the SSH connection. Type y to the question proposed.

$ ssh -i "example-key-pair.pem" ec2-user@YOUR_PUBLIC_DNS_NAME

The authenticity of host 'ec2-xxxxxxxxxxxx.compute-1.amazonaws.com (www.zz.xxx.yy)' can't be established.
ECDSA key fingerprint is SHA256:wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ec2-xxxxxxxxxxxx.compute-1.amazonaws.com,www.zz.xxx.yy' (ECDSA) to the list of known hosts.

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
13 package(s) needed for security, out of 32 available
Run "sudo yum update" to apply all updates.
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

[ec2-user@ip-xxxxxxxxxxxx ~]$ 
Enter fullscreen mode Exit fullscreen mode

Discussion (0)