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

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.

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong ยท web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video ๐ŸŒถ๏ธ๐Ÿ”ฅ

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

๐Ÿ‘‹ Kindness is contagious

If you found this post helpful, please leave a โค๏ธ or a friendly comment below!

Okay