Reputation: 177
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.
Upvotes: 11
Views: 33218
Reputation: 1
See this solution: https://stackoverflow.com/a/60732304/2210719
Quickly, you need to add the ec2-instance-connect package if you use the Linux version other than Amazon Linux.
Upvotes: 0
Reputation: 1258
IPv6 was the lurking problem. Adding inbound firewall/security rule for SSH with ::/0 worked for me.
Only 0.0.0.0/0 was added in the security configuration to allow all incoming SSH connections.
I tried to add a new IPv6 security configuration with "::/0" (Anywhere-IPv6) and then I was able to connect to the EC2 instance from my machine seamlessly. This basically allows us to connect from anywhere even if our IP is IPv6.
The following steps worked:
Make sure 0.0.0.0/0 IPv4 firewall rule for SSH is already added. And Voila!
Upvotes: -1
Reputation: 9
You can use EC2 Instance Connect with your ssh client. In case you really need the browse-based connection, your security group must have a rule allowing SSH connections (port 22) from 0.0.0.0/0. Not much secure in my point of view...
Upvotes: 0
Reputation: 5687
This is for AWS Lightsail, I could not use browser to connect via SSS, instead I was able to connect via SSH using macOS terminal. I was able to login via SSH by appending my public key id_rsa.pub contents to the remote authorized_keys file, I used SFTP (Filezilla) to update authorized_keys file. For SFTP connection I downloaded ssh key from Accounts page.
Upvotes: 2
Reputation: 269322
To test, I just did the following:
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.
Upvotes: 9