Menu
Amazon Elastic Container Service
Developer Guide (API Version 2014-11-13)

Connect to Your Container Instance

To perform basic administrative tasks on your instance, such as updating or installing software or accessing diagnostic logs, connect to the instance using SSH. To connect to your instance using SSH, your container instances must meet the following prerequisites:

  • Your container instances need external network access to connect using SSH. If your container instances are running in a private VPC, they need an SSH bastion instance to provide this access. For more information, see the Securely connect to Linux instances running in a private Amazon VPC blog post.

  • Your container instances must have been launched with a valid Amazon EC2 key pair. Amazon ECS container instances have no password, and you use a key pair to log in using SSH. If you did not specify a key pair when you launched your instance, there is no way to connect to the instance.

  • SSH uses port 22 for communication. Port 22 must be open in your container instance security group for you to connect to your instance using SSH.

    Note

    The Amazon ECS console first-run experience creates a security group for your container instances without inbound access on port 22. If your container instances were launched from the console first-run experience, add inbound access to port 22 on the security group used for those instances. For more information, see Authorizing Network Access to Your Instances in the Amazon EC2 User Guide for Linux Instances.

To connect to your container instance

  1. Find the public IP or DNS address for your container instance.

    1. Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.

    2. Select the cluster that hosts your container instance.

    3. On the Cluster page, choose ECS Instances.

    4. On the Container Instance column, select the container instance to connect to.

    5. On the Container Instance page, record the Public IP or Public DNS for your instance.

  2. Find the default username for your container instance AMI. The user name for instances launched with the Amazon ECS-optimized AMI is ec2-user. For Ubuntu AMIs, the default user name is ubuntu. For CoreOS, the default user name is core.

  3. If you are using a macOS or Linux computer, connect to your instance with the following command, substituting the path to your private key and the public address for your instance:

    Copy
    $ ssh -i /path/to/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com

    If you are using a Windows computer, see Connecting to Your Linux Instance from Windows Using PuTTY in the Amazon EC2 User Guide for Linux Instances.

    Important

    If you experience any issues connecting to your instance, see Troubleshooting Connecting to Your Instance in the Amazon EC2 User Guide for Linux Instances.