Header Ads

How to Open SSH Port in EC2?

How to Open SSH Port in EC2

EC2 (Elastic Compute Cloud) is a popular cloud computing service provided by Amazon Web Services (AWS). It offers virtual servers that can be used to host websites, run applications, and perform other computing tasks. To access these servers remotely, you need to use Secure Shell (SSH) protocol. By default, SSH port is closed in EC2 instances for security reasons. In this article, we will discuss how to open SSH port in EC2 instances.


  • An EC2 instance running on AWS.
  • AWS account credentials with necessary permissions to modify EC2 security group rules.
  • Basic knowledge of Linux and AWS CLI.

Step 1: Login to AWS Console and Navigate to EC2 Dashboard

Login to your AWS account and navigate to the EC2 dashboard. From there, select the EC2 instance for which you want to open the SSH port.

Step 2: Check the Security Group of the EC2 Instance

EC2 instances are associated with one or more security groups that act as a virtual firewall to control inbound and outbound traffic. To open the SSH port, we need to modify the inbound rules of the security group associated with the EC2 instance.

To check the security group associated with the EC2 instance, select the instance and navigate to the Description tab. Look for the Security groups field, which shows the name of the associated security group.

Step 3: Modify Inbound Rules of the Security Group

To modify the inbound rules of the security group, navigate to the Security Groups tab and select the associated security group. From there, select the Inbound Rules tab and click on Edit.

In the Edit inbound rules dialog box, click on Add Rule and select SSH from the Type dropdown menu. In the Source field, select My IP to allow SSH access only from your current IP address. Alternatively, you can select Anywhere to allow SSH access from any IP address. Click on Save Rules to apply the changes.

Step 4: Test the SSH Connection

Now that you have opened the SSH port, you can test the connection by using an SSH client such as PuTTY (Windows) or Terminal (Mac/Linux). Launch the SSH client and enter the public IP address of the EC2 instance as the hostname. Use the default port 22 for SSH connections.

If the connection is successful, you should be prompted to enter the login credentials for the EC2 instance.

More Examples:

  • To allow SSH access from a specific IP range, select Custom IP and enter the IP range in CIDR notation (e.g.,
  • To allow SSH access from another EC2 instance in the same security group, select Custom and enter the ID of the other instance (e.g., sg-0123456789abcdef0).

Opening the SSH port in EC2 instances is a simple process that can be done using the AWS console or AWS CLI. By following the above steps, you can allow SSH access to your EC2 instances securely. Remember to keep the security group rules up-to-date to avoid any security vulnerabilities.

Related Searches and Questions asked:

  • How to SSH into EC2 Using Linux?
  • How to Connect SSH in AWS Linux?
  • How to Connect to AWS Server through SSH?
  • How Does SSH Work in AWS?
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.

    يتم التشغيل بواسطة Blogger.