# How to Enable SSM Connect in EC2 
Instances 💡

Managing AWS EC2 instances without worrying about SSH keys is a big relief, and AWS Systems Manager (SSM) Session Manager makes it even easier. It provides a secure way to connect to your instances. In this guide, I will walk you through the steps to enable SSM Connect in your EC2 instances, making your cloud management more secure, efficient, and hassle-free.

---

# Step 1: Create and Attach an IAM Role to the EC2 Instance 🍳

* Navigate to the **AWS IAM Console** and go to **Roles**.
    
* Click **Create role**.
    
* Select **AWS Service** and choose **EC2**, then click **Next**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1739026072372/58af2129-3904-4dce-ac55-83ddd4fd4b65.png align="center")
    
* In the permissions section, search for and attach the following policy:
    
    * `AmazonSSMManagedInstanceCore` (required for SSM agent to communicate with AWS Systems Manager)
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1739026163658/3e7ec9fe-affe-432f-8738-21f10be7b614.png align="center")
        
* Click **Next**, give the role a name (e.g., `SSMManagedEC2`), and create the **role**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1739026217279/61023b26-1910-4b2b-91c2-4bdabaeabdf5.png align="center")
    
* Attach the IAM role to your EC2 instance:
    
    * Go to the **EC2 Console** &gt; Select your instance
        
    * Click **Actions** &gt; **Security** &gt; **Modify IAM Role**
        
    * Select the IAM role you created and click **Update IAM Role**
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1739027865069/93fa0c8f-322a-4b58-abd2-6e7616fb1e9a.png align="center")
        

---

# Step 2: Verify SSM Agent is Installed and Running ✅

> 📌 Check out for SSM agent Verification details: [AWS Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/ami-preinstalled-agent.html)

For Ubuntu, run the following command to check if the agent is installed:

```sh
sudo systemctl status snap.amazon-ssm-agent.amazon-ssm-agent.service
```

> 📌 If the agent is not installed, then refer this link for installation: [Manually installing and uninstalling SSM Agent](https://docs.aws.amazon.com/systems-manager/latest/userguide/manually-install-ssm-agent-linux.html)

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Note:</strong> It may take some time for the installation to take effect. To apply the changes quickly ⚡, restart the SSM agent or reboot the EC2 instance.</div>
</div>

---

# Step 3: Access EC2 Instance Using SSM 🚀

Now you can access your EC2 instance using SSM through the AWS Console or AWS CLI.

## Option 1: Using the AWS Console 💻

1. Navigate to **AWS Systems Manager Console**.
    
2. Click the **EC2 instance** you want to access.
    
3. Click **Connect**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1739028751828/289f5563-53f3-4a37-aa4f-f55af8b02eb8.png align="center")
    
4. Click **Session Manager** and then **Connect** to open a shell session.
    

## Option 2: Using AWS CLI ⚡

To access EC2 via the local terminal or AWS CLI, install the **SSM Agent** on your local machine using the following commands:

```apache
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"
sudo dpkg -i session-manager-plugin.deb
```

For other OS versions, refer to the [SSM Plugin Installation](https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html).

Run the following command to enter an EC2 machine via SSM through the terminal. 🥳

```sh
aws ssm start-session --target <instance-id>
```

> 📌 Make sure your AWS CLI is configured with the right permissions and region settings.

---

# Conclusion 🎃

Enabling SSM Connect in EC2 instances enhances security, eliminates the need for SSH keys, and simplifies instance management. By following these steps, you can securely manage your AWS environment with AWS Systems Managers “Session Manager”.

---

📬Do you have any questions or need further assistance? Leave a comment below or explore my other AWS tutorials for more cloud management tips!
