DEV Community

Rahul Wagh
Rahul Wagh

Posted on • Originally published at jhooq.com

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

Terraform SSH into EC2 instance instruction guide? - https://jhooq.com/terraform-ssh-into-aws-ec2/
How to handle SSH keys in AWS? - https://youtu.be/S5B09dq-jGQ

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)