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 2. Connect to EC2 via SSH in VS Code Press shift + ctrl + P at the same time, and select Remote SSH: Connect to Host. Click + Add New SSH Host..., type the following and press enter. ec2-user@XX.XX.XX.XX 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 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 ~]$ 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. 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.

Feb 23, 2025 - 06:38
 0
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 

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
  • 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 ~]$

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.