Course Content
Introduction to Cloud Computing
Introduction to Cloud Computing
Connecting to the Instance From Your Device
In the last chapters, 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 general.
Connecting to an EC2 instance gives you full control over a remote virtual machine running on Amazon servers. Here are the main reasons and capabilities that SSH connection provides:
- Software Management: You can install, update, and uninstall software on your instance;
- System Configuration: You can modify configuration files and system settings, for example, to optimize server performance or configure a web server;
- File Management: You can upload, move, modify, and delete files on your server. This allows you to host a website, as in your case, or manage application data;
- Running and Managing Services: You can manage services and processes and start and stop them as needed.
Connecting to the Instance
There are several ways to connect to the instance. We'll cover 2 of them. The first way will be connecting to the instance through the terminal on your device. This way, 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 matter.
So let's start 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 located, the username in AWS (by default, it's ec2-user
for Linux), and also the public DNS of your instance:
You can view your instance's public DNS by opening the instance in your instance list:
Note
In this course, you will need basic navigation commands in bash to manage a virtual machine remotely. If you don't know them, it's okay because I will show you all the commands and explain what they do.
After executing this command, you will get the following result:
Thus, we have gained access to the remote server and can manage it.
Connecting Through AWS Terminal
The second method will be easier in some places than the first one, but this method is less efficient because we sacrifice some features and the appearance of a real hacker who works only through the console.
To connect through AWS, we need to click on the large Connect
button at the top right:
When you click the button, it will take you to a menu where you will be offered several connection options. Choose "Connect using EC2 Instance Connect" and click on Connect
:
Note
By the way, here you can also read about how to connect via SSH key, as I described in the first method.
After that, the console will open right in your browser, allowing us to remotely manage the virtual machine:
Now we have the ability to manage the virtual computer directly from the browser console.
Common Connection Errors
One of the most common errors when connecting to an instance is improperly configured Security Groups, specifically the SSH connection entry.
If you are unable to establish a connection and the error persists upon retrying, check the security group associated with this instance and see if there is an entry allowing SSH access from any IP via port 22
. It should allow IP 0.0.0.0/0
for this purpose.
This entry should look like this:
Afterward, there could be various reasons. If you encounter errors after checking multiple times, feel free to write "Give feedback about this chapter," and I'll try to help you as soon as possible!
Everything was clear?