Want to **remotely connect Visual Studio Code (VS Code) to an AWS EC2 instance** via SSH? 🚀 In this step-by-step tutorial, I’ll show you how to **set up remote SSH in VS Code**, so you can edit and work on your AWS server just like a local machine. By the end of this video, you’ll learn: ✅ How to **install and configure the VS Code Remote SSH extension** ✅ How to **set up an SSH connection to your AWS EC2 instance** ✅ How to **edit files and run commands on EC2 from VS Code** ✅ How to **troubleshoot common SSH connection issues** — ## **🔹 What You’ll Learn in This Video:** ✔️ How to **generate an SSH key or use an existing AWS key pair** ✔️ How to **install the Remote – SSH extension in VS Code** ✔️ How to **configure the SSH connection in VS Code** ✔️ How to **connect, edit files, and manage EC2 remotely** — ## **🔹 Prerequisites** ✔️ An **AWS EC2 Instance** (Ubuntu, Amazon Linux, etc.) ✔️ **Visual Studio Code (VS Code)** installed ([Download Here](https://code.visualstudio.com/)) ✔️ **Remote – SSH Extension** installed in VS Code ✔️ An **SSH Key (`.pem` file)** downloaded from AWS — ## **🔹 Step 1: Install VS Code and Remote – SSH Extension** 1️⃣ Open **VS Code** 2️⃣ Go to **Extensions** (or press `Ctrl + Shift + X`) 3️⃣ Search for **"Remote – SSH"** and install it 4️⃣ Once installed, restart VS Code — ## **🔹 Step 2: Configure SSH in VS Code** 1️⃣ Open VS Code 2️⃣ Press **`Ctrl + Shift + P`** (or `Cmd + Shift + P` on Mac) to open the Command Palette 3️⃣ Search for **"Remote-SSH: Open Configuration File"** and select it 4️⃣ Choose the **SSH config file** (`~/.ssh/config` on Mac/Linux or `C:\Users\your-username\.ssh\config` on Windows) — ## **🔹 Step 3: Add Your AWS EC2 Instance to the SSH Config** In the SSH config file, add the following: “`plaintext
Host aws-ec2 HostName your-ec2-public-ip User ubuntu IdentityFile C:\path\to\your-key.pem
“` 💡 **Replace:** – `aws-ec2` → Any name you want for the connection – `your-ec2-public-ip` → The public IP of your AWS EC2 instance – `User ubuntu` → Use `ec2-user` for Amazon Linux, `ubuntu` for Ubuntu – `IdentityFile` → The path to your AWS private key (`.pem` file) — ## **🔹 Step 4: Connect to AWS EC2 from VS Code** 1️⃣ Open **VS Code** 2️⃣ Press **`Ctrl + Shift + P`** and search for **"Remote-SSH: Connect to Host"** 3️⃣ Select the host (`aws-ec2`) from the list 4️⃣ VS Code will open a new window and **connect to your EC2 instance** 🚀 — ## **🔹 Step 5: Edit and Work on EC2 Remotely** ✔️ **Open Terminal in VS Code** (`Ctrl + ~`) and run commands on EC2 ✔️ **Edit files directly from VS Code** as if they were local ✔️ **Run Python, Node.js, or any other scripts remotely** — ## **🔹 Troubleshooting SSH Issues** 🔹 **Permission Denied (publickey)?** ✅ **Fix:** Ensure your **.pem file has correct permissions** (`chmod 400 your-key.pem`) 🔹 **Cannot Connect to EC2?** ✅ **Fix:** Make sure **port 22 (SSH) is open in the EC2 security group** 🔹 **Wrong User?** ✅ **Fix:** Check if you need `ubuntu`, `ec2-user`, or `root` for login — ## **🔹 Who Is This Tutorial For?** ✅ **Developers** deploying code on AWS ✅ **Cloud engineers** managing remote servers ✅ **Beginners** setting up AWS for the first time — ## **🔹 More AWS Tutorials:** 📌 **How to Set Up AWS EC2 Instance (Free Tier)** → [Watch Now] 📌 **How to Deploy a Flask App on AWS EC2** → [Watch Now] 📌 **How to Connect MySQL on AWS RDS from VS Code** → [Watch Now] — ## **👍 Like, Share & Subscribe!** If this tutorial helped you, **LIKE, SHARE, and SUBSCRIBE** for more AWS, DevOps, and Cloud Computing tutorials! 🚀 💬 Have questions? Drop them in the **comments** below! — ### **🔹 Hashtags:** #AWS #EC2 #VisualStudioCode #VSCode #RemoteSSH #CloudComputing #DevOps #Ubuntu #AmazonLinux #Cloud #SysAdmin #Python #Docker