EC2 Amazon Web Services
Introduction
EC2
- Elastic Compute Cloud
A web service that provides computing power in the cloud.
The service is part of the
Amazon Web Services (AWS)
.
The simple web interface of the service lets you get access to computing
power and configure it with minimal resource costs.
It gives users full control over computing resources,
as well as a convenient environment to work in.
The service reduces the time needed to obtain and boot a new server.
With EC2 you can:
- Create an Amazon Machine Image ( AMI ), which will contain your applications, libraries, data and the associated configuration parameters. Or use preconfigured image templates for your work;
- Upload the AMI to Amazon S3 . Amazon EC2 provides tools for storing AMIs. Amazon S3 provides secure, reliable and fast storage for keeping images;
- Use the Amazon EC2 web service to configure security and network access;
- Choose the operating system type(s) you need, start, stop or monitor several AMIs as needed, using the web service API or the various management tools provided;
- Decide whether you need to work in several locations, use a static IP or other options;
- Pay only for the resources you are going to consume, such as time or data transfer.
Connecting to a Linux system
1
Connect to the Linux instances you launched and transfer
files between your local computer and your instance.
For information about connecting to a Windows instance see the "Connecting to your Windows instance" section in the Amazon EC2 User Guide for Windows Instances.
Connection options
The operating system of your local computer determines the options for connecting from the local computer to a Linux instance.
If your local computer runs Linux or macOS X
If your local computer runs Windows
Connecting to a Linux system over SSH
1
After launching your instance you can connect to it and use it just
as you would use a computer sitting in front of you.
The following instructions explain how to connect to your instance
using an SSH client.
If an error occurs when you try to connect to the instance,
see the section
Troubleshooting instance connections
.
For more connection options see the
section
Connecting to your Linux instance
.
When you launch an instance in AWS for the first time you will be asked to choose an access type
- choose paired-keys and save your private key
(.pem) to the client computer.
Remember where you saved it. Suppose you saved the key in the directory /path/
Prerequisites
Before connecting to a Linux system, meet the following conditions.
Check the status of your instance
After the instance is launched, a few minutes may pass before the instance
is ready and you can connect to it.
Make sure that your instance has passed the status check.
You can view this information in the status check column on the instances page.
Get the public DNS name and the user name for connecting to your instance
topbicycle.awsapps.com/start#/ → Management Console
→ EC2 → Instances (all states) → Instance state → Wait until
the status becomes
Running
Get the public DNS name and the user name for connecting to your instance
To find the public DNS name or IP address of your instance and the user name you should use to connect to your instance, see the section connection prerequisites for your instance .
Install an SSH client on your local computer as needed
Your local computer may have an SSH client installed by default. You can check this by typing ssh in the command line. If your computer does not recognize this command, you can install an SSH client.
- Recent versions of Windows Server 2019 and Windows 10 have OpenSSH included as an installable component. For more information see the section OpenSSH in Windows
- Earlier versions of Windows - download and install OpenSSH. For more information see the section Win32-OpenSSH
- Linux and macOS X - download and install OpenSSH. For more information see openssh.com
Connecting to a Linux system using an SSH client
Use the following procedure to connect to your Linux instance using an SSH client. If an error occurs when you try to connect to the instance, see the section Troubleshooting instance connections .
To connect to your instance using SSH
-
In a terminal window, run 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 IPv6 address for your instance.
For more information about how to find the private key, the user name for your instance and the DNS name or IPv6 address for the instance, see the sections Finding the private key and getting information about your instance .
To connect to your instance, use one of the following commands.
-
(Public DNS) To connect using the public DNS name of your instance, enter the following command.
ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name
You can see the exact command by going to the instance page (to do this you need to click its Instance ID)
There you need to click the button Connect and select SSH client
This tab contains detailed information about exactly which command you must run to connect to the instance
Let us examine this command in more detail.
- /path/ is the directory into which you saved the .pem key
- my-key-pair.pem is the key name. You came up with it yourself.
-
my-instance-user-name
is your user name
You can find out your user name on the instance page in the section Connect
By default the user name for EC2 is ec2-user -
my-instance-public-dns-name is the name of your host as seen from
the internet
You can see it on the page Instances in the column Pulic IPv4 DNS or by going to the instance page (to do this you need to click its Instance ID)
Usually it consists of
ec2 + IPv4 address + Availability Zone Name
Your command will look roughly like this
ssh -i /path/key_name.pem ec2-user@ec2-198-51-100-1.us-west-1.compute.amazonaws.com
-
(IPv6) In addition, if your instance has an IPv6 address, to connect using
the IPv6 address of your instance, enter the following command.
ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-IPv6-address
You see a response like this:
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)? -
(Public DNS) To connect using the public DNS name of your instance, enter the following command.
- (Optional) make sure that the fingerprint in the security warning matches the fingerprint obtained earlier (optional) Get the instance fingerprint. If these fingerprints do not match, someone may be trying to perform an MITM attack . If they match, go to the next step.
-
Enter yes.
You will see a similar response:
Warning: Permanently added 'ec2-198-51-100-1.compute-1.amazonaws.com' (RSA)
to the list of known hosts.
Sending file modes: C0644 20 SampleFile.txt
Sink: C0644 20 SampleFile.txt
SampleFile.txt
Article author: Andrei Olegovich