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.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
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.
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.
Open SSH Configuration File
Click on “Open SSH Configuration File” from the Remote SSH menu.
Select and open the config file to configure the remote instance details.
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.
Connect to the Remote Instance
Click on the Remote SSH icon again on the far left corner of the status bar.
Select “Connect to Host”.
Choose the hostname you specified in the configuration file.
Select “Linux” if it is a Linux-based instance and click “Continue”.
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
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
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.
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
Comments