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.

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

👋 Kindness is contagious

If you found this post helpful, please leave a ❤️ or a friendly comment below!

Okay