AWS, Cloud Computing

4 Mins Read

Streamline Your Development Connecting Remote Instances to VS Code

Voiced by Amazon Polly

Introduction

In this blog, we will learn how to connect your remote machine (in my case, Amazon EC2 instance) with your VS Code editor.

Suppose you are actively working on a remote Linux-based instance and need to do lots of frequent editing or changes to your code. In that case, it is a hassle as the default IDE it comes with is not at all user friendly and does not provide or come with an advanced feature that comes with the VS Code. Still, we cannot use it in the CLI version, but there is a way to SSH or connect to your Amazon EC2 instance or any remote instance from VS Code from your local system and work directly from your IDE.

Benefits

Connecting to an Amazon EC2 instance from within VS Code offers several advantages:

  • Seamless Code Editing: Edit code and files as they are on your local system.
  • Advanced Features: Utilize all VS Code plugins, shortcuts, and advanced editing features.
  • Simplified Workflow: Eliminate the hassle of syncing code between your local system and the remote instance.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Prerequisite

  • A running Linux based Amazon EC2 instance with a public IP address attached to it.
  • Visual Studio Code (VS Code) installed in the system.

Steps to Implement

Configure Security Group for SSH

Log in to the AWS console.

Navigate to the security group of the Amazon EC2 instance you want to connect to.

Create a new inbound rule for SSH and allow your current system’s IP address to enable SSH access to the remote instance.

Install Remote – SSH Extension

Open VS Code on your system.

Go to the Extensions view by clicking the Extensions icon in the Activity Bar on the side of the window.

Search for “Remote – SSH” in the VS Code marketplace and install the extension.

Access Remote SSH

Once the extension is installed, you will see a new icon on the far left side of the status bar. This icon provides quick access to Remote SSH.

Click on this Remote SSH icon.

step1

Open SSH Configuration File

Click on “Open SSH Configuration File” from the Remote SSH menu.

step2

Select and open the config file to configure the remote instance details.

step3

Configure the Remote Instance

In the config file, paste the following code:

Host <any name of your choice>

HostName <host IP address>

IdentityFile <location of the key>

User <user name>

Host: A name that will appear in VS Code. It can be any name.

HostName: The server’s IP address or host.

User: The username of the instance or machine.

IdentityFile: The path to the private key file.

Save the configuration file.

step4

Connect to the Remote Instance

Click on the Remote SSH icon again on the far left corner of the status bar.

step5

Select “Connect to Host”.

step6

Choose the hostname you specified in the configuration file.

step7

Select “Linux” if it is a Linux-based instance and click “Continue”.

step8

Access Files and Folders

Once connected, you can browse the files and folders of your remote instance.

Go to File > Open Folder in VS Code to open a folder.

Conclusion

Connecting a remote instance, such as an Amazon EC2 instance, to VS Code significantly enhances the development experience. By following the steps outlined, you can seamlessly integrate your remote server’s environment with the powerful features of VS Code. This integration allows for efficient code editing, advanced plugins, and a streamlined development process, ultimately boosting productivity and reducing the hassle of manually syncing files.

With the setup completed, you can enjoy a smooth and efficient workflow, making remote development as convenient as working on your local machine.

Drop a query if you have any questions regarding Amazon EC2 and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery PartnerAWS Microsoft Workload PartnersAmazon EC2 Service Delivery Partner, and many more.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.

FAQs

1. What should I do if I encounter connection issues?

ANS: – Ensure your security group allows SSH connections from your current IP address. Double-check the SSH configuration file for any errors in the hostname, IP address, username, or path to the private key.

2. Can I connect to any remote server using this method?

ANS: – Yes, as long as the remote server supports SSH connections and you have the necessary access credentials.

WRITTEN BY Yamini Reddy

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!