How to SSH into an Elastic Beanstalk Instance

Step 1: Create a Key Pair

  • On the AWS Console, navigate to EC2 in the region corresponding to your Elastic Beanstalk Environment.
  • From the left side menu, under ‘Network and Security’, click on ‘Key Pairs’.
  • Click on ‘Create Key Pair’, and provide a name, select ‘RSA’ as the type, and .pem as the file format, and click on ‘Create key pair’.

A .pem file will be downloaded on your machine. Remember where you store it. I will be storing it in d:/keys/ on my Windows machine.

Step 2: Add the Key Pair to the Elastic Beanstalk Environment

  • On the AWS Console, navigate to the Elastic Beanstalk environment you want to SSH into
  • From the left pane, click on ‘Configuration’, and click on ‘Edit’ next to the ‘Security’ option.
  • Select the EC2 Key Pair you just created in the ‘EC2 key pair’ section.
  • Click on ‘Apply’. The changes will take effect.

Step 3: Identify the Public IPv4 DNS of your instance

  • Navigate to the EC2 Console, and identify the instance corresponding to the Elastic Beanstalk environment that you would like to SSH into.
  • Copy the Public IPv4 DNS

Step 4: SSH into your instance

  • Open a command prompt/terminal on your machine
  • Type the following command
ssh -i <path_to_pem> ec2-user@<public_ipv4_dns>

So, in this example, the BASH command would be:

ssh -i d:/keys/ElasticBeanstalkKeyPair.pem [email protected]

It may give you a warning saying the authenticity of the host can’t be established, and will ask you to continue. Click on yes. You will now have SSHed into your instance! Congratulations!

I hope you liked this article. For more tutorials on AWS, check out Also, if you are planning to become a certified AWS Solutions Architect, I’d recommend that you check out this course on Udemy. I took this course and found the lectures to be lucid, to-the-point, and fun. I hope they will help you as well.

Leave a comment

Your email address will not be published. Required fields are marked *