Course Content
Introduction to Cloud Computing
Introduction to Cloud Computing
Connecting to the Instance From Your Device
We created and configured an instance on AWS EC2; now, let's see how we can connect to the instance and start working with it.
First, let's understand why we need to connect to an EC2 instance in the first place.
Connecting to an EC2 instance gives you full access to a remote virtual machine running on Amazon's infrastructure. Here are the main reasons and capabilities that an SSH connection provides:
- Software management: you can install, update, and remove software on your instance;
- System configuration: you can edit configuration files and adjust system settings, such as optimizing server performance or setting up a web server;
- File management: you can upload, move, edit, and delete files on your server. This lets you host a website, like in your case, or manage application data;
- Running and managing services: you can control services and processes, starting and stopping them as necessary.
Connecting to the Instance
There are a few ways to connect to the instance. We'll go over two of them.
The first method is connecting to the instance via the terminal on your device. With this method, you'll be managing the instance remotely through the terminal on your machine. I'm working on a MacOS, so I'll be demonstrating through its console, but keep in mind that it doesn't matter which device we're using, as most of the time we'll be managing a Linux server, where the platform doesn't make a difference.
Now, let's begin with the first method.
Connection via Terminal
To connect, we need to use our private SSH key. In the terminal, you need to enter the path to where this SSH key is stored, the username in AWS (by default, it's ec2-user
for Linux), and also the public DNS of your instance:
You can find your instance's public DNS by opening the instance from your instance list:
After running this command, you should see the following result:
So, we've successfully accessed the remote server and can now manage it.
Connecting Through AWS Terminal
The second method will be simpler in some aspects than the first one, but it is less efficient because we lose some features.
To connect via AWS, click on the large "Connect" button at the top right:
When you click the button, it will redirect you to a menu with several connection options. Select "Connect using EC2 Instance Connect" and then click on "Connect":
After that, the console will open directly in your browser, enabling us to manage the virtual machine remotely:
Now, we can manage the virtual machine directly from the browser console.
Common Connection Errors
One of the most common errors when trying to connect to an instance is improperly configured Security Groups, particularly the SSH connection entry.
If you're unable to make the connection and the error keeps happening when you try again, check the security group associated with this instance to see if there's an entry that allows SSH access from any IP on port 22
. It should allow IP 0.0.0.0/0
for this purpose.
This entry should look like this:
After that, there could be various reasons. Feel free to leave feedback in this chapter, and I'll do my best to help you!
1. What does connecting to an EC2 instance allow you to do?
2. What is the default username when connecting to a Linux EC2 instance via SSH?
3. How can you view your instance’s public DNS?
4. What common error might prevent you from connecting to your EC2 instance?
Thanks for your feedback!