top of page
Writer's picturevP

Lab 1 - Connecting to Your First Ubuntu EC2 Instance - Day 74

Hello and Welcome back to our #90DaysOfDevOps Series. In one of the previous blog, we have seen how to create an EC2 instance. In this blog post, I'll guide you through your first practical task: connecting to your Ubuntu-based Amazon EC2 instance. Now, let's explore how to connect to it and perform some basic tasks.


There are multiple ways to connect to EC2 instance.

Select the instance to which you want to connect and Click on Connect.


You'll be redirected to another window where you can see 4 different options to connect to the instance.


a. EC2 Instance Connect

EC2 Instance Connect allows secure access to your instance through SSH. EC2 Instance Connect provides multiple options to connect to your instance without sharing your SSH keys.


b. Session Manager

Session Manager allows secure access to the managed nodes without opening inbound ports, or managing an SSH key. You can use AWS CloudTrail events to audit Session Manager sessions, and control the sessions with AWS Identity and Access Management (IAM) policies.


c. SSH Client

You can use Secure Shell (SSH) to connect to your Linux instance from a local machine that runs a Linux or macOS operating system.


d. EC2 Serial Console

The EC2 serial console establishes a serial connection to EC2 instances that allows you to troubleshoot boot and network connectivity issues.

  • Public DNS name of your EC2 instance

  • SSH client installed on your local machine (e.g., PuTTY for Windows)


In this blog post, I'll be using the first option to connect to EC2. For more details regarding the other options, you can refer to this blog.


Once you click on Connect, it'll open a console in another tab.


Checking the Hostname:

Once connected, type the following command:

hostname

This will display the current hostname of your EC2 instance.


 Updating the Hostname:

  1. To change the hostname, edit the /etc/hostname file using your preferred text editor (e.g., nano):

sudo nano /etc/hostname
  1. Replace the existing hostname with your desired one.

  2. Save the file and close the editor.

  3. Restart the hostname service:

sudo hostnamectl set-hostname <new_hostname>
  1. Verify the change by running the hostname command again.


Essential Maintenance Tasks:

  • Update the system packages:

sudo apt update
sudo apt upgrade
  • Install essential tools:

sudo apt install git vim unzip
  • Set up a firewall:

sudo ufw enable
  • Configure SSH access:

sudo nano /etc/ssh/sshd_config

Congratulations! You've successfully connected to your Ubuntu EC2 instance and performed some basic maintenance tasks. Remember, this is just the beginning of your journey with AWS. 


Keep exploring, experiment, and unleash the power of cloud computing!


Thank you for reading!


*** Explore | Share | Grow ***

12 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page