amazon-web-servicesamazon-ec2sshvpc-endpointaws-ec2-instance-connect

ec2 instance connect endpoint: kex_exchange_identification: Connection closed by remote host


I am following this documentation and I try to ssh to the private ec2. I have created the ec2 connect endpoint and I am able to use to connect from the console.

When using ssh from my mac terminal, I have below message:

ssh -i <key-pair>.pem ec2-user@i-xxxxxxx -o ProxyCommand='aws ec2-instance-connect open-tunnel --instance-id i-xxxxxxx'

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: argument operation: Invalid choice, valid choices are:

send-ssh-public-key                      | send-serial-console-ssh-public-key      
help                                    

kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

Below is the version of the aws cli I am using:

aws --version
aws-cli/2.11.27 Python/3.11.3 Darwin/22.5.0 exe/x86_64 prompt/off

My vpc endpoint connect endpoint:

ec2 instance connect endpoint

How to fixe the ssh connection ?


Solution

  • The new EC2 Instance Connect Endpoint feature will be added to AWS CLI v2 once the version 2.12.0 is released, referring to the official change log. I expect the repositories will be updated very soon with the latest version of the AWS CLI.

    Edit: it is available now. I tested with my EC2s and it is perfectly working. If you are having the same issue, you just need to update your AWS CLI to the latest version.