DEV Community

Rahul Wagh
Rahul Wagh

Posted on • Originally published at


Terraform how to SSH into AWS EC2 instance? - Part 10

Terraform SSH into EC2 instance instruction guide? -
How to handle SSH keys in AWS? -

While working with the AWS EC2 instance you do not get a Username and password to SSH into your EC2 instance. You have to either generate the SSH keys and associate the public key with the EC2 instance. After that, you need to use your private key to SSH into the virtual machine running in the AWS cloud.

On similar lines, if you are using Terraform to provision your AWS infrastructure you need to associate the public key with your terraform script and after starting the EC2 instance you need to use your private key to SSH into the EC2 instance.

In this lab session, we are going to perform the following steps -

  1. Generate key-pair(public key, private key) using ssh-keygen
  2. Use public key to start EC2 instance
  3. Use the private key to SSH into EC2 instance

Top comments (0)

Forem is hiring a Senior Platform Engineer

computer on fire

Are you capable of chipping in across sysadmin, ops, and site reliability work, while supporting the open source stack that runs DEV and other communities?

This role might just be for you!

Apply now