I found it to be a 2-step process. This assumes that you've already set up a keypair to access EC2 instances in the relevant region.
Configure Security Group
In the AWS console, open the EC2 tab.
Select the relevant region and click on Security Group.
You should have an elasticbeanstalk-default
security group if you have launched an Elastic Beanstalk instance in that region.
Edit the security group to add a rule for SSH access. The below will lock it down to only allow ingress from a specific IP address.
SSH | tcp | 22 | 22 | 192.168.1.1/32
Configure the environment of your Elastic Beanstalk Application
- If you haven't made a key pair yet, make one by clicking Key Pairs below Security Group in the ec2 tab.
- In the AWS console, open the Elastic Beanstalk tab.
- Select the relevant region.
- Select relevant Environment
- Select Configurations in left pane.
- Select Security.
- Under "EC2 key pair:", select the name of your keypair in the
Existing Key Pair
field.
If after these steps you see that the Health is set Degraded
that's normal and it just means that the EC2 instance is being updated. Just wait on a few seconds it'll be Ok again
Once the instance has relaunched, you need to get the host name from the AWS Console EC2 instances tab, or via the API. You should then be able to ssh onto the server.
$ ssh -i path/to/keypair.pub [email protected]
Note: For adding a keypair to the environment configuration, the instances' termination protection must be off as Beanstalk would try to terminate the current instances and start new instances with the KeyPair.
Note: If something is not working, check the "Events" tab in the Beanstalk application / environments and find out what went wrong.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…