We use machine learning technology to do auto-translation. Click "English" on top navigation bar to check Chinese version.
Secure Connectivity from Public to Private: Introducing EC2 Instance Connect Endpoint
This blog post is written by Ariana Rahgozar, Solutions Architect, and Kenneth Kitts, Sr. Technical Account Manager, Amazon Web Services.
Imagine trying to connect to an
Today we launched
In this post, we provide an overview of how the EIC Endpoint works and its security controls, guide you through your first EIC Endpoint creation, and demonstrate how to SSH to an instance from the Internet over the EIC Endpoint.
EIC Endpoint product overview
EIC Endpoint is an identity-aware TCP proxy. It has two modes: first, Amazon Web Services CLI client is used to create a secure, WebSocket tunnel from your workstation to the endpoint with your
Figure 1. User connecting to private EC2 instances through an EIC Endpoint
EIC Endpoints provide a high degree of flexibility. First, they don’t require your VPC to have direct Internet connectivity using an IGW or NAT Gateway. Second, no agent is needed on the resource you wish to connect to, allowing for easy remote administration of resources which may not support agents, like third-party appliances. Third, they preserve existing workflows, enabling you to continue using your preferred client software on your local workstation to connect and manage your resources. And finally, IAM and
Prior to the launch of EIC Endpoints, Amazon Web Services offered two key services to help manage access from public address space into a VPC more carefully. First is
Given that EIC Endpoint enables access to private resources from public IP space, let’s review the security controls and capabilities in more detail before discussing creating your first EIC Endpoint.
Security capabilities and controls
Many Amazon Web Services customers remotely managing resources inside their VPCs from the Internet still use either public IP addresses on the relevant resources, or at best a bastion host approach combined with long-lived SSH keys. Using public IPs can be locked down somewhat using IGW routes and/or security groups. However, in a dynamic environment those controls can be hard to manage. As a result, careful management of long-lived SSH keys remains the only layer of defense, which isn’t great since we all know that these controls sometimes fail, and so defense-in-depth is important. Although bastion hosts can help, they increase the operational overhead of managing, patching, and maintaining infrastructure significantly.
IAM authorization is required to create the EIC Endpoint and also to establish a connection via the endpoint’s secure tunneling technology. Along with identity-based access controls governing who, how, when, and how long users can connect, more traditional network access controls like security groups can also be used. Security groups associated with your VPC resources can be used to grant/deny access. Whether it’s IAM policies or security groups, the default behavior is to deny traffic unless it is explicitly allowed.
EIC Endpoint meets important security requirements in terms of separation of privileges for the control plane and data plane. An administrator with full EC2 IAM privileges can create and control EIC Endpoints (the control plane). However, they cannot use those endpoints without also having EC2 Instance Connect IAM privileges (the data plane). Conversely, DevOps engineers who may need to use EIC Endpoint to tunnel into VPC resources do not require control-plane privileges to do so. In all cases, IAM principals using an EIC Endpoint must be part of the same Amazon Web Services account (either directly or by cross-account role assumption). Security administrators and auditors have a centralized view of endpoint activity as all API calls for configuring and connecting via the EIC Endpoint API are recorded in
EIC Endpoint supports the optional use of Client IP Preservation (a.k.a Source IP Preservation), which is an important security consideration for certain organizations. For example, suppose the resource you are connecting to has network access controls that are scoped to your specific public IP address, or your instance access logs must contain the client’s “true” IP address. Although you may choose to enable this feature when you create an endpoint, the default setting is off . When off, connections proxied through the endpoint use the endpoint’s private IP address in the network packets’ source IP field. This default behavior allows connections proxied through the endpoint to reach as far as your route tables permit. Remember, no matter how you configure this setting, CloudTrail records the client’s true IP address.
EIC Endpoints strengthen security by combining identity-based authentication and authorization with traditional network-perimeter controls and provides for fine-grained access control, logging, monitoring, and more defense in depth. Moreover, it does all this without requiring Internet-enabling infrastructure in your VPC, minimizing the possibility of unintended access to private VPC resources.
Getting started
Creating your EIC Endpoint
Only one endpoint is required per VPC. To create or modify an endpoint and connect to a resource, a user must have the required IAM permissions, and any security groups associated with your VPC resources must have a rule to allow connectivity. Refer to the following resources for more details on
The Amazon Web Services CLI or Console can be used to create an EIC Endpoint, and we demonstrate the Amazon Web Services CLI in the following. To create an EIC Endpoint using the Console, refer to the
Creating an EIC Endpoint with the Amazon Web Services CLI
To create an EIC Endpoint with the Amazon Web Services CLI, run the following command, replacing [SUBNET] with your subnet ID and [SG-ID] with your security group ID:
aws ec2 create-instance-connect-endpoint \ --subnet-id [SUBNET] \ --security-group-id [SG-ID]
After creating an EIC Endpoint using the Amazon Web Services CLI or Console, and granting the user IAM permission to create a tunnel, a connection can be established. Now we discuss how to connect to Linux instances using SSH. However, note that you can also use the OpenTunnel API to connect to instances via
Connecting to your Linux Instance using SSH
With your EIC Endpoint set up in your VPC subnet, you can connect using SSH. Traditionally, access to an EC2 instance using SSH was controlled by key pairs and network access controls. With EIC Endpoint, an additional layer of control is enabled through IAM policy, leading to an enhanced security posture for remote access. We describe two methods to connect via SSH in the following.
One-click command
To further reduce the operational burden of creating and rotating SSH keys, you can use the new ec2-instance-connect ssh
command from the Amazon Web Services CLI. With this
Once configured, you can connect using the new Amazon Web Services CLI command, shown in the following figure:
Figure 3. Amazon Web Services CLI view upon successful SSH connection to your instance
To test connecting to your instance from the Amazon Web Services CLI, you can run the following command where [INSTANCE] is the instance ID of your EC2 instance:
aws ec2-instance-connect ssh --instance-id [INSTANCE]
Note that you can still use long-lived SSH credentials to connect if you must maintain existing workflows, which we will show in the following. However, note that dynamic, frequently rotated credentials are generally safer.
Open-tunnel command
You can also connect using SSH with standard tooling or using the proxy command. To establish a private tunnel (TCP proxy) to the instance, you must run one Amazon Web Services CLI command, which you can see in the following figure:
You can run the following command to test connectivity, where [INSTANCE] is the instance ID of your EC2 instance and [SSH-KEY] is the location and name of your SSH key. For guidance on the use of SSH keys, refer to our documentation on
ssh ec2-user@[INSTANCE] \ -i [SSH-KEY] \ -o ProxyCommand='aws ec2-instance-connect open-tunnel \ --instance-id %h'
Once we have our EIC Endpoint configured, we can SSH into our EC2 instances without a public IP or IGW using the Amazon Web Services CLI.
Conclusion
EIC Endpoint provides a secure solution to connect to your instances via SSH or RDP in private subnets without IGWs, public IPs, agents, and bastion hosts. By configuring an EIC Endpoint for your VPC, you can securely connect using your existing client tools or the Console/Amazon Web Services CLI. To learn more, visit the
The mentioned AWS GenAI Services service names relating to generative AI are only available or previewed in the Global Regions. Amazon Web Services China promotes AWS GenAI Services relating to generative AI solely for China-to-global business purposes and/or advanced technology introduction.