SSH to Elastic Beanstalk instance
I just signed up for Amazon's new Elastic Beanstalk offering and loving it. What I can't figure out is how to SSH to a Beanstalk instance. I don't have a private key because Beanstalk generated the instance on my behalf. Ideas?
Thanks, Benno
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
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
Existing Key Pair
field. 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 ec2-user@ec2-an-ip-address.compute-1.amazonaws.com
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.
Elastic beanstalk CLI v3 now supports direct SSH with the command eb ssh
. Eg
eb ssh your-environment-name
No need for all the hassle of setting up security groups of finding out the EC2 instance address.
There's also this cool trick:
eb ssh --force
That'll temporarily force port 22 open to 0.0.0.0, and keep it open until you exit
. This blends a bit of the benefits of the top answer, without the hassle. You can temporarily grant someone other than you access for debugging and whatnot. Of course you'll still need to upload their public key to the host for them to have access. Once you do that (and as long as you're inside eb ssh
), the other person can
ssh ec2-user@ec2-xx-xxx-xxx-xx.compute-1.amazonaws.com
My experience in August 2013 with a linux client and a simple AWS Beanstalk installation (single EC2 instance) is as follows (based on Community Wiki above)
Configure Security Group
awsweb...
security group and the details should show at the base of the page Create Public-Private Key Pair
Associate the Public Private Key Pair with the Elastic Beanstalk EC2 Server
Connect to AWS EC2 Instance using SSH
Good luck
链接地址: http://www.djcxy.com/p/32540.html