EC2 Instance Login - Comparison between the keypair, EC2 Instance Connect, and Session Manager (Systems Manager)

AWS provides three options to log on to your EC2 instances: Traditional SSH Keypair-based login, EC2 Instance Connect, and SSM Session Manager.

Here is a short comparison of these approaches.

This article is from my Security Specialty and SAA Udemy courses.

SSH Keypair

Advantages

  • Strong cryptographic security compared to using user IDs and passwords.
  • The private key (secret) is securely stored on the client side, while the public key is stored on the server side.
  • Two-factor authentication is possible by securing the private key with a passphrase.
  • Granular access control as a unique key can be issued to each user for specific server access.
  • Widely supported

Disadvantages

  • Requires careful key management practices, including protecting private keys.
  • Periodic key rotation is necessary.
  • Revoking access to the key can be challenging, as you need to touch each server that allows access to the keys.
  • Managing keys in large-scale environments or with multiple users can be challenging.

EC2 Instance Connect

Advantages

  • Eliminates the need for managing and sharing SSH keys
  • Manages instance access using IAM-based security controls
  • Authorized users can push temporary or single-use SSH public keys to the server
  • Supports traditional tools like SSH, SFTP, and so forth
  • Security group and network controls to limit access from specific IP ranges
  • AWS EC2 Instance Connect CLI provides a simple and single command to automatically login to EC2
  • You can also easily setup a tunnel to use other tools like SFTP or WinSCP
  • Supports connecting to both public and private instances (with endpoints), eliminating the need for Bastion Hosts.
  • Multiple options to connect: Browser-based console login, and CLI
  • Support for Linux and Windows. For Windows, you need to launch an instance with keypair to retrieve the password and then set up the tunnel

Disadvantages

  • Requires EC2 Instance Connect agent on the server
  • Requires learning additional tools and commands
  • A sixty-second timer is set from when the public key is pushed to the server until login. But the session can be for as long as you need once you login.
  • Requires configuring security group rules to handle access through EC2 Instance Connect Public Endpoints, Client IP address, Instance Connect Private Endpoint

Session Manager

Advantages

  • Eliminates the need for managing and sharing SSH keys
  • Manages instance access using IAM-based security controls
  • Uses TLS tunnel for logging into the server
  • Supports connecting to both public and private instances (with endpoints), eliminating the need for Bastion Hosts.
  • Support for Linux and Windows

Disadvantages

  • Integration with traditional tools like SSH, SFTP, and WinSCP can be challenging.
  • Bypasses Security Group
  • Requires the SSM agent to be installed on the server
  • More complex setup and usage

Please feel free to share which option you prefer and use!

Best

Chandra Lingam, Compute With Cloud Inc

Good comparison, Chandra. AWS has recently launched another option "EC2 Instance Connect Endpoint" to connect to the EC2 instances running in private networks. So you don't need a bastion host or public IP to access the instance. That will be a more secure and cost effective option. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-using-eice.html

To view or add a comment, sign in

More articles by Chandra Mohan Lingam

  • Save Money on SageMaker Usage

    There are three different ways to save some money on your SageMaker usage. · SageMaker Savings Plan for steady-use…

  • World’s largest migration

    Recent changes to Whatsapp privacy policies have triggered a lot of discussion in Social media. This picture…

  • Recommender Systems using Factorization Machines

    Recommender System is a type of machine learning problem that has some interesting characteristics: Recommendations are…

  • Nuts and Bolts of Optimization

    Introduction This article is a summary of an excellent presentation by Dr. Andrew Ng on Nuts and Bolts of Applied Deep…

    5 Comments
  • Data breach

    A look at the recent attack and how to protect your application Capital One was hacked in 2019, and the data breach…

    1 Comment
  • [Updated Dec 2020] - My experience taking AWS SAA C02, and C01 exams

    [updated] When I took the SAA-C02 exam in May-2020, I was not too happy with the questions' quality. This is what I…

    1 Comment
  • AWS SAA-C02 Updates

    I have a major AWS SAA-C02 content update for this month to my courses. Global Accelerator Global Accelerator is a…

  • Cloud Security in AWS

    Learn the current best practices in managing cloud security. When to use identity-based and resource-based policies…

  • Keeping up with AWS Changes

    Frequent questions I get on AWS are: "How do I keep up with all the changes happening in AWS?" "Do I have to know all…

    1 Comment
  • AWS Tip: KMS & Envelope Encryption

    Encryption is used for protecting your data at rest and during transit. Security here hinges on properly protecting the…

Explore content categories