DEV Community

Cover image for Different Methods to Connect to a AWS Linux Compute Engine Instance
Ahmad Majeed Zahoory
Ahmad Majeed Zahoory

Posted on • Edited on

Different Methods to Connect to a AWS Linux Compute Engine Instance

Step 1: Connect via ssh using Key pair
Process:

  • Create a key pair in the .ppk format (or .pem format if you need an alternative to using an SSH tool) and download the private key to your local desktop or laptop.
  • Attach the Key pair during the creation of the AWS virtual machine.

Image-1

  • Copy the Public IP of the virtual machine.

Image-2

  • Follow these steps to connect to a Linux instance:
  • Launch PuTTY or another compatible tool.
  • Expand Connection > SSH > Auth and select credentials.
  • Click Browse and locate your private key file.

Image-3

  • The Linux terminal will open and ask for a username. Enter the appropriate username based on the Linux distribution (e.g., "ec2-user" for Amazon Linux or "ubuntu" for Ubuntu).

Image-4

Step 2: Connect via ssh using own SSH Key defined in the Key pair
Process:

  • On your local machine, generate an SSH key pair.
  • Save public key and private key, on your local machine.

Image-5

  • Navigate to the Key pair page and choose "Actions"
  • Click on "Import Key Pair" and add your public key

Image-6

  • Attach the Key pair during the creation of the AWS virtual machine.

Image-7

  • Copy the Public IP of the virtual machine.
  • Follow these steps to connect to a Linux instance:
  • Launch PuTTY or another compatible tool.
  • Expand Connection > SSH > Auth and select credentials.
  • Click Browse and locate your private key file.
  • The Linux terminal will open and ask for a username. Enter the appropriate username based on the Linux distribution (e.g., "ec2-user" for Amazon Linux or "ubuntu" for Ubuntu).

Image-8

Step 3: Connect via AWS Console
Process:

  • Create the AWS virtual machine.
  • Go to the EC2 page and select "Instances."
  • Find your Linux virtual machine and click "Connect."
  • Choose "EC2 Instance Connect" and then "Connect using EC2 Instance Connect."
  • Finally, click "Connect".

Image-9

  • A browser-based terminal will launch, providing direct access to the instance.

Image-10

Step 4: Connect via AWS System manager
Process:

  • Create an IAM role and attach the "AmazonSSMManagedInstanceCore" policy.
  • Attach the IAM role while creating the AWS virtual machine.

Image-11

  • Navigate to the System Manager page and choose "Session Manager"
  • Click on "Start Session."
  • Wait until the Linux instance appears, then select it and click "Start Session."

Image-12

  • A browser-based terminal will launch, providing direct access to the instance.

Image-13

Step 5: Connect via ssh using password
Process:

  • While creating the Linux virtual machine.
  • In the Advanced details section:
  • Copy the script below (adjust it according to your Linux distribution) under user data.
#!/bin/bash
echo 'lab-password' | passwd ec2-user --stdin
sed -i 's|[#]*PasswordAuthentication no|PasswordAuthentication yes|g' /etc/ssh/sshd_config
systemctl restart sshd.service
Enter fullscreen mode Exit fullscreen mode

Image-14

  • Copy the Public IP of the virtual machine.
  • Follow these steps to connect to a Linux instance:
  • Launch PuTTY or another compatible tool.
  • The Linux terminal will open and ask for a username and password. Enter the appropriate username based on the Linux distribution (e.g., "ec2-user" for Amazon Linux or "ubuntu" for Ubuntu) and password.

Image-15

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more