Search code examples
amazon-ec2

EC2 Instance Connect (browser-based SSH connection) doesn't work


Trying to connect Amazon AWS EC2 instance fails.

Platform: Amazon Linux

Connection method: EC2 Instance Connect (browser-based SSH connection)

Error: There was a problem setting up the instance connection Log in failed. If this instance has just started up, try again in a minute or two.

Note: I am able to connect via Putty / SSH Client. But same instance can't connect via browser.

When checked network logs in browser's developer tool, see a Status Code: 400 Bad Request for following URL:

https://ec2-instance-connect.us-east-2.managed-ssh.aws.a2z.com/ls/api/tokens

Has anyone ever successfully connected to Amazon Linux EC2 instance from browser.


Solution

  • To test, I just did the following:

    • Launched an Amazon Linux 2 EC2 instance with the default security group
    • Clicked "Connect" in the EC2 management console
    • Selected "EC2 Instance Connect"
    • Clicked "Connect"

    A new browser tab opened and a few seconds later I had a working SSH connection.

    I then tried it again with an Amazon Linux (not Amazon Linux 2) instance and got the error:

    There was a problem setting up the instance connection
    Log in failed. If this instance has just started up, try again in a minute or two.

    This is because the EC2 Instance Connect client is only pre-installed on Amazon Linux 2 and Ubuntu 16.04 or later.