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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay