DEV Community

Cover image for How to Integrate an AWS EC2 Instance with VS Code using Remote SSH
Ryoichi Homma
Ryoichi Homma

Posted on • Edited on

1 1 2 1

How to Integrate an AWS EC2 Instance with VS Code using Remote SSH

Developing directly on Amazon EC2 instance can improve workflow efficiency and eliminate the need for constant file transfers. This article will explain how to integrate an EC2 instance with VS Code using the Remote - SSH extension.

Prerequisites

  • AWS EC2 instance running
  • SSH access to your EC2 instance
  • VS Code installed on your local machine

1. Install VS Code Extension

Remote SSH

2. Connect to EC2 via SSH in VS Code

  • Press shift + ctrl + P at the same time, and select Remote SSH: Connect to Host.
    Step1

  • Click + Add New SSH Host..., type the following and press enter.

ec2-user@XX.XX.XX.XX 
Enter fullscreen mode Exit fullscreen mode

Step2

  • Select the top one, .ssh\config to open the config file and add the following:
Host ec2-server
  HostName XX.XX.XX.XX
  User ec2-user
  IdentityFile ~/ec2
  ForwardAgent yes
Enter fullscreen mode Exit fullscreen mode
  • Open the Remote Explore tab on the left sidebar.
  • Under SSH Targets, locate ec2-server.
  • Click the connect arrow (→).
  • Select the correct OS for the remote machine.
  • If SSH: ec2-server appears at the bottom left and the terminal shows something like:
[ec2-user@ip-xx-xx-xx-xx ~]$
Enter fullscreen mode Exit fullscreen mode

You have successfully connected to the remote EC2 instance.

3. Transfer Project Folder

  • Simply drag and drop your project folder to the root directory of the EC2 instance. Root directory

By following these steps, you should be able to integrate the EC2 instance with VS Code. This setup improves development efficiency and allows seamless remote coding in a cloud environment.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay