My journey to AWS Solution Architect Exam — Part 6— Amazon Elastic Compute Cloud EC2 (2/4)

MayBeMan
4 min readJan 8, 2024

--

Security Groups serve as the cornerstone of network security within the AWS environment. These vital components play a pivotal role in controlling traffic to and from our Elastic Compute Cloud (EC2) instances. In essence, Security Groups act as virtual firewalls for EC2 instances, regulating various aspects of network communication.

Understanding and effectively configuring Security Groups is imperative for establishing a robust network security foundation within the AWS ecosystem. By comprehending these principles and best practices, users can ensure the secure and efficient operation of their EC2 instances.

Key Features of Security Groups

  • Allow Rules Only

Security Groups exclusively consist of allow rules. These rules dictate how traffic is permitted, and they form the basis for securing the communication channels to and from EC2 instances.

  • Rule References

Security Group rules can be defined based on either IP addresses or other Security Groups. This flexibility enables a fine-grained control over the network traffic, allowing for precise configuration.

  • Default Behavior

Inbound Traffic: By default, all inbound traffic is blocked, emphasizing a secure-by-default approach to network communication.
Outbound Traffic: Conversely, all outbound traffic is authorized by default, facilitating outbound communication without unnecessary constraints.

Firewall Functionality

Acting as a firewall, Security Groups govern the following aspects:

  • Access to specific ports
  • Authorization of IP ranges for both IPv4 and IPv6
  • Control over inbound network traffic
  • Control over outbound network traffic

Additional Insights

  • Versatility: A single Security Group can be attached to multiple instances, providing a scalable and efficient approach to managing network security across various resources.
Control traffic to your AWS resources using security groups — Amazon Virtual Private Cloud
  • Regional and VPC Limitations: Security Groups are confined to specific regions and Virtual Private Cloud (VPC) combinations. This localization ensures that security policies are consistently enforced within defined boundaries.
  • External to EC2 Instances: Security Groups operate independently of the EC2 instances. If traffic is blocked by a Security Group, the associated EC2 instance remains unaware of the attempted communication.
  • Specialized Security Group for SSH Access: best practices recommend maintaining a separate Security Group dedicated to Secure Shell (SSH) access. This focused approach enhances the security posture of instances that require SSH connections.

Troubleshooting Tips

  • Timeout Issues: in case an application becomes inaccessible and times out, it is likely attributed to a Security Group misconfiguration.
  • “Connection Refused” Errors: if an application returns a “connection refused” error, the problem may lie either with the application itself or its launch status rather than the Security Group settings.

Classic Ports Overview (Good to know)
22 (SSH): Secure Shell for logging into Linux instances securely.
21 (FTP): File Transfer Protocol for uploading files to a file share.
22 (SFTP): Secure File Transfer Protocol, utilizing SSH for file uploads.
80 (HTTP): Access to unsecured websites.
443 (HTTPS): Access to secured websites.
3389 (RDP): Remote Desktop Protocol for logging into Windows instances.

EC2 Instance Connect

EC2 Instance Connect is a service provided by AWS that simplifies the process of connecting to EC2 instances through the web browser, eliminating the need to use the downloaded private key file. Here are some key points on this topic:

  • Browser-based Connection: EC2 Instance Connect allows you to connect directly to EC2 instances using a web browser, making the process more convenient and accessible.
  • No Need for Key File: traditionally, connecting to an EC2 instance requires using a private key (PEM file) for authentication. With EC2 Instance Connect, this private key is no longer required for the connection.
  • Temporary Key uploaded to EC2: the “magic” of EC2 Instance Connect lies in the fact that a temporary key is uploaded directly to your EC2 instance by AWS when you attempt to connect. This key is only valid for the current connection session and is deleted after use.
  • Port 22 Open: to use EC2 Instance Connect, it is crucial to ensure that port 22, which is the default SSH port, is open in the security group settings of your EC2 instance. SSH access is necessary to establish the connection to your instance.
  • Works natively only with Amazon Linux 2 instances. This means that for other Linux distributions or operating systems, you may need to continue using the traditional method with private keys.

In summary, EC2 Instance Connect streamlines the process of connecting to EC2 instances through the browser, eliminating the need to manually manage private keys.

--

--

MayBeMan
MayBeMan

Written by MayBeMan

Technician specialized in the security of electronic payment systems. Crypto supporter.

No responses yet