Giter Site home page Giter Site logo

session-manager's Introduction

session-manager

Going Bastion-less: Accessing Private EC2 instance with Session Manager

Why use Session Manager?

It is well known that we can not directly connect to a private EC2 instance unless there is VPN Connectivity or Direct Connect or other network connectivity source with the VPC. A common approach to connect to an EC2 instance on a private subnet of your VPC is to use a Bastion Host.

A Bastion Host is a server whose purpose is to provide access to a private network from an external network (such as the Internet). Because of its exposure to potential attacks, a bastion host must minimize the chances of penetrations. When using a bastion host, you log into the bastion host first, and then into your target private instance. With this approach, only the bastion host will have an external IP address.

However, there are some drawbacks:

  • You will need to allow SSH inbound rule at your bastion
  • You need to open ports on your private EC2 instance in order to connect it to your bastion
  • You will need to manage the SSH key credentials of your users: You will need to generate an ssh key pair for each user or get a copy of the same SSH key for your users
  • Cost: The bastion host also has a cost associated with it as it is a running EC2 instance. Even a t2.micro costs about $10/month.

Session Manager can be used to access instances within private subnets that allow no ingress from the internet. AWS SSM provides the ability to establish a shell on your systems through its native service, or by using it as a tunnel for other protocols, such as Secure Shell (SSH).

Advantages:

  • It will log the commands issued during the session, as well as the results. You can save the logs in s3 if you wish.
  • Shell access is completely contained within Identity and Access Management (IAM) policies, you won’t need to manage SSH keys
  • The user does not need to use a bastion host and Public IPs.
  • No need to open the ports in the security groups

Network configuration used:

image

For SSM manager to send its logs to S3 bucket and Cloudwatch logs. We will create S3 bukcer (ssm-demo) and cloudwatch loggroup (ssmdemo). Now goto session manager and from Preferneces enable s3 logging and cloudwatch log.

S3 bucket:

image

Cloudwatch Log:

image

Session manager Sessiongs:

image

image

image

Now to be able to access the EC2 instnace using session manager create ssm-role and attached AmazonSSMManagedInstanceCore, AmazonS3FullAccess and CloudWatchLogsFullAccess.

image

Now cerate a EC2 instance in private subnet and attached ssm-role to it.

image

Connect to instance using session manager:

image

image

Session logs uplocaded in s3 bucket:

image

Session logs uploaded in cloudwatch log:

image

session-manager's People

Contributors

cloudtechmasters avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.