<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shiho Toyoshima</title>
    <description>The latest articles on DEV Community by Shiho Toyoshima (@_6adda1ae80b627cc84b8).</description>
    <link>https://dev.to/_6adda1ae80b627cc84b8</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3894078%2F7c008cb7-5f4f-4cde-9817-f4d3a6d22f42.png</url>
      <title>DEV Community: Shiho Toyoshima</title>
      <link>https://dev.to/_6adda1ae80b627cc84b8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_6adda1ae80b627cc84b8"/>
    <language>en</language>
    <item>
      <title># Stop Managing SSH Keys: 3 Modern Ways to Connect to Your EC2 Instances with AWS SSM</title>
      <dc:creator>Shiho Toyoshima</dc:creator>
      <pubDate>Thu, 23 Apr 2026 14:03:54 +0000</pubDate>
      <link>https://dev.to/_6adda1ae80b627cc84b8/-stop-managing-ssh-keys-3-modern-ways-to-connect-to-your-ec2-instances-with-aws-ssm-2a6l</link>
      <guid>https://dev.to/_6adda1ae80b627cc84b8/-stop-managing-ssh-keys-3-modern-ways-to-connect-to-your-ec2-instances-with-aws-ssm-2a6l</guid>
      <description>&lt;p&gt;Have you ever lost an SSH key and been locked out of your EC2 instance? Or spent hours managing key pairs across a team, only to have a security audit flag them as a risk? If you're still connecting to EC2 the old-fashioned way — opening port 22, juggling &lt;code&gt;.pem&lt;/code&gt; files, and maintaining a bastion host — there's a better approach.&lt;/p&gt;

&lt;p&gt;AWS Systems Manager (SSM) offers three connection methods that eliminate SSH keys entirely. No open inbound ports. No bastion servers. Just clean, auditable, IAM-controlled access.&lt;/p&gt;

&lt;p&gt;In this article, we'll walk through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How traditional SSH/RDP connections work (and why they're painful)&lt;/li&gt;
&lt;li&gt;What SSM is, and the shared prerequisites for all three methods&lt;/li&gt;
&lt;li&gt;The three SSM-based connection methods and how each one works under the hood&lt;/li&gt;
&lt;li&gt;How each method handles security and what users can do&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - A practical guide for choosing the right method
&lt;/h2&gt;

&lt;h2&gt;
  
  
  The Old Way: SSH and Direct RDP
&lt;/h2&gt;

&lt;p&gt;Before diving into SSM, let's quickly recap what most people are currently doing.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSH (Linux instances)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-i&lt;/span&gt; my-keypair.pem ec2-user@&amp;lt;public-ip&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the classic approach. You generate a key pair in AWS, download the &lt;code&gt;.pem&lt;/code&gt; file, and use it to authenticate. To make this work, you need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open &lt;strong&gt;port 22 inbound&lt;/strong&gt; in your security group&lt;/li&gt;
&lt;li&gt;Keep the instance reachable over the internet (or set up a bastion host for private subnets)&lt;/li&gt;
&lt;li&gt;Manage and distribute key pairs to every team member who needs access
The pain points are real: keys get lost, leaked, or forgotten. Rotating them across a team is tedious. And that open port 22 is a constant target for brute-force attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Direct RDP (Windows instances)
&lt;/h3&gt;

&lt;p&gt;For Windows instances, you connect via Remote Desktop Protocol (RDP). AWS uses the key pair not for direct authentication, but to &lt;strong&gt;decrypt the Windows administrator password&lt;/strong&gt;. You retrieve this password from the AWS console, then use an RDP client like &lt;code&gt;mstsc&lt;/code&gt; to connect.&lt;/p&gt;

&lt;p&gt;Requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open &lt;strong&gt;port 3389 inbound&lt;/strong&gt; in your security group&lt;/li&gt;
&lt;li&gt;A public IP address (or bastion host for private subnets)&lt;/li&gt;
&lt;li&gt;The key pair to decrypt the initial admin password
Both approaches share the same fundamental problems: open inbound ports and the overhead of key management. SSM solves both.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Is AWS Systems Manager (SSM)?
&lt;/h2&gt;

&lt;p&gt;AWS Systems Manager is a service for managing AWS infrastructure at scale. One of its most useful features is &lt;strong&gt;Session Manager&lt;/strong&gt;, which enables secure shell and GUI connections to EC2 instances — without any open inbound ports.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shared prerequisites for all three SSM methods
&lt;/h3&gt;

&lt;p&gt;Before you can use any of the three connection methods below, your EC2 instance needs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;SSM Agent installed and running&lt;/strong&gt; — Pre-installed on Amazon Linux 2, Amazon Linux 2023, and most Windows AMIs. Other OS types may require manual installation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An IAM role attached to the instance&lt;/strong&gt; — The role must include the &lt;code&gt;AmazonSSMManagedInstanceCore&lt;/code&gt; managed policy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outbound HTTPS (port 443) access to SSM endpoints&lt;/strong&gt; — Either via an internet gateway (public subnets) or VPC endpoints (private subnets).
Once these are in place, your instance appears as a "managed node" in SSM, and all three connection methods become available.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Three SSM-Based Connection Methods
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. SSM Session Manager
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; Shell access to Linux or Windows instances&lt;/p&gt;

&lt;p&gt;Session Manager gives you an interactive shell session directly from the AWS Management Console or AWS CLI — no SSH client, no key pair, no open ports required.&lt;/p&gt;

&lt;h4&gt;
  
  
  How it works
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your browser / AWS CLI
        │
        │  IAM authentication + SigV4 signing
        ▼
  Session Manager Service  ──── TLS 1.2 encrypted channel ────▶  SSM Agent on EC2
        │                                                               │
        └──────────────── ssmmessages VPC endpoint (optional) ─────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you start a session:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Session Manager authenticates your identity and validates your IAM permissions.&lt;/li&gt;
&lt;li&gt;It sends a message to the SSM Agent on the target instance to open a bidirectional channel.&lt;/li&gt;
&lt;li&gt;All traffic between your client and the instance is encrypted with &lt;strong&gt;TLS 1.2&lt;/strong&gt;, and the connection request is signed with &lt;strong&gt;SigV4&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Command input and output stream through this channel in real time.
The instance never needs an inbound port open. The SSM Agent initiates an outbound connection to the SSM service — the traffic flows out, not in.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  What you can do
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Run bash or PowerShell commands interactively&lt;/li&gt;
&lt;li&gt;View and edit files, inspect processes, tail logs&lt;/li&gt;
&lt;li&gt;Connect from a browser (AWS Console) or AWS CLI&lt;/li&gt;
&lt;li&gt;Apply fine-grained access control using IAM conditions (e.g., restrict access by EC2 tag)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Record all session activity to S3 or CloudWatch Logs for auditing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2. SSM Port Forwarding + RDP
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; GUI access to Windows instances using your existing RDP client&lt;/p&gt;

&lt;p&gt;This method uses Session Manager to create an encrypted tunnel between your local machine and the EC2 instance. You then point your RDP client at a local port, and SSM forwards the traffic through the tunnel to port 3389 on the instance.&lt;/p&gt;

&lt;h4&gt;
  
  
  How it works
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RDP Client (mstsc, etc.)
        │
        │  connects to localhost:&amp;lt;local-port&amp;gt;
        ▼
  AWS CLI + Session Manager Plugin
        │
        │  HTTPS (port 443) — TLS tunnel
        ▼
  Session Manager Service
        │
        │  TLS tunnel
        ▼
  SSM Agent on EC2  ──▶  RDP port 3389 (internal only)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To start a session, you run a single AWS CLI command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ssm start-session &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--target&lt;/span&gt; &amp;lt;instance-id&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--document-name&lt;/span&gt; AWS-StartPortForwardingSession &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--parameters&lt;/span&gt; &lt;span class="s2"&gt;"portNumber=3389,localPortNumber=55678"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open your RDP client and connect to &lt;code&gt;localhost:55678&lt;/code&gt;. SSM forwards all traffic to port 3389 on the instance — but &lt;strong&gt;port 3389 is never exposed to the internet&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  What you need
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;AWS CLI with the &lt;strong&gt;Session Manager Plugin&lt;/strong&gt; installed&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Any RDP client you're already using&lt;/p&gt;
&lt;h4&gt;
  
  
  What you can do
&lt;/h4&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Full GUI desktop experience via your familiar RDP client&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use RDP's built-in features: clipboard sharing, file transfer, printer/drive redirection&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Keep using your existing workflow — SSM just handles the secure tunneling
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3. SSM Fleet Manager
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Best for:&lt;/strong&gt; GUI access to Windows instances entirely from the browser&lt;/p&gt;

&lt;p&gt;Fleet Manager takes the RDP experience and moves it entirely into the AWS Management Console. There's nothing to install on your local machine — just open your browser, navigate to the Fleet Manager console, and click "Connect with Remote Desktop."&lt;/p&gt;

&lt;h4&gt;
  
  
  How it works
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your Browser (AWS Console)
        │
        │  HTTPS
        ▼
  Fleet Manager (Amazon DCV protocol)
        │
        │  TLS encrypted channel
        ▼
  SSM Agent on Windows EC2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the hood, Fleet Manager uses &lt;strong&gt;Amazon DCV&lt;/strong&gt; (Desktop Cloud Visualization), a high-performance remote display protocol that streams the Windows desktop to your browser. The entire connection stays within AWS — no RDP traffic ever reaches the public internet.&lt;/p&gt;

&lt;p&gt;You can have up to &lt;strong&gt;4 simultaneous connections&lt;/strong&gt; open in a single browser window.&lt;/p&gt;

&lt;h4&gt;
  
  
  What you can do
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Full GUI desktop access with nothing but a browser&lt;/li&gt;
&lt;li&gt;Connect via &lt;strong&gt;IAM Identity Center (SSO)&lt;/strong&gt; — no Windows password needed if configured&lt;/li&gt;
&lt;li&gt;Manage multiple instances side by side&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - One-click access from the EC2 instance list
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Security: How Each Method Stays Safe
&lt;/h2&gt;

&lt;p&gt;All three methods share a common security foundation:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Security layer&lt;/th&gt;
&lt;th&gt;Session Manager&lt;/th&gt;
&lt;th&gt;Port Forwarding + RDP&lt;/th&gt;
&lt;th&gt;Fleet Manager&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Authentication&lt;/td&gt;
&lt;td&gt;IAM policy&lt;/td&gt;
&lt;td&gt;IAM policy&lt;/td&gt;
&lt;td&gt;IAM policy + SSO support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Encryption&lt;/td&gt;
&lt;td&gt;TLS 1.2 (+ optional KMS)&lt;/td&gt;
&lt;td&gt;TLS 1.2 tunnel wrapping RDP&lt;/td&gt;
&lt;td&gt;Amazon DCV protocol&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inbound ports required&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSH keys required&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Session audit log&lt;/td&gt;
&lt;td&gt;Full command log (S3 / CloudWatch)&lt;/td&gt;
&lt;td&gt;Session start event only (CloudTrail)&lt;/td&gt;
&lt;td&gt;Session start event only (CloudTrail)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access control granularity&lt;/td&gt;
&lt;td&gt;Instance, tag, or region level&lt;/td&gt;
&lt;td&gt;Instance level&lt;/td&gt;
&lt;td&gt;Instance level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Private subnet support&lt;/td&gt;
&lt;td&gt;Yes (VPC endpoints)&lt;/td&gt;
&lt;td&gt;Yes (VPC endpoints)&lt;/td&gt;
&lt;td&gt;Yes (VPC endpoints)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The key difference: audit depth
&lt;/h3&gt;

&lt;p&gt;Session Manager is the only method that can record &lt;strong&gt;what commands were run&lt;/strong&gt; during a session. If you need to demonstrate to a security auditor exactly what an engineer did during a maintenance window, Session Manager with S3 logging is your answer.&lt;/p&gt;

&lt;p&gt;Port Forwarding and Fleet Manager record that a session happened (via CloudTrail), but the contents of the RDP session — the mouse clicks and keystrokes — are not captured.&lt;/p&gt;




&lt;h2&gt;
  
  
  Choosing the Right Method
&lt;/h2&gt;

&lt;p&gt;Use this as a quick reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Is the OS Linux?
├── Yes → Session Manager (CUI is fine for Linux workloads)
└── No (Windows only)
    ├── Do you need full RDP features (file transfer, clipboard, drive redirection)?
    │   └── Yes → Port Forwarding + RDP
    └── Can you install AWS CLI on the local machine?
        ├── Yes → Port Forwarding + RDP  or  Fleet Manager (your choice)
        └── No  → Fleet Manager
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Scenario quick-reference
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Recommended method&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Troubleshooting a production Linux server&lt;/td&gt;
&lt;td&gt;Session Manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuring IIS or Active Directory on Windows Server&lt;/td&gt;
&lt;td&gt;Port Forwarding + RDP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Managing multiple Windows servers via SSO&lt;/td&gt;
&lt;td&gt;Fleet Manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Running deployment scripts from a CI/CD pipeline&lt;/td&gt;
&lt;td&gt;Session Manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accessing EC2 from a locked-down corporate laptop&lt;/td&gt;
&lt;td&gt;Fleet Manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Developers who want to keep using their RDP client&lt;/td&gt;
&lt;td&gt;Port Forwarding + RDP&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Here's what we covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Traditional SSH / RDP&lt;/strong&gt; requires open inbound ports, key pair management, and often a bastion host. These add operational overhead and attack surface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSM&lt;/strong&gt; eliminates all of that. Every method uses IAM for authentication and outbound-only HTTPS for communication — no inbound ports, no SSH keys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session Manager&lt;/strong&gt; is the most versatile: CUI access to Linux and Windows, with full command logging. Ideal for automation, auditing, and production environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Port Forwarding + RDP&lt;/strong&gt; lets you keep your existing RDP client workflow while adding SSM's security layer. Best when you need RDP's full feature set (file transfer, clipboard, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fleet Manager&lt;/strong&gt; requires nothing on the local machine — just a browser. Best for Windows-only environments and teams that want centralized, browser-based access.&lt;/p&gt;
&lt;h3&gt;
  
  
  Next steps
&lt;/h3&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started.html" rel="noopener noreferrer"&gt;Session Manager setup guide — AWS docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html" rel="noopener noreferrer"&gt;Port forwarding with Session Manager — AWS docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/fleet-manager-remote-desktop.html" rel="noopener noreferrer"&gt;Fleet Manager Remote Desktop — AWS docs&lt;/a&gt;&lt;br&gt;
If you're still using SSH keys and bastion hosts, try spinning up a test instance with the &lt;code&gt;AmazonSSMManagedInstanceCore&lt;/code&gt; policy attached and connecting via Session Manager. The setup takes about 10 minutes — and you may never go back.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Found this useful? Drop a comment with which method you're using in your team — I'd love to hear how others are managing EC2 access.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ec2</category>
      <category>rdp</category>
      <category>ssm</category>
    </item>
  </channel>
</rss>
