WebOTG

Posted on by
connect-ubuntu-lightsail-to-vscode-windows
VS Code Remote SSH with Ubuntu Lightsail

Connecting Ubuntu (AWS Lightsail) to VS Code on Windows

Using Password Authentication & Resolving SSH Host Key Verification Errors

Overview

This document describes how to connect an Ubuntu server (AWS Lightsail) to Visual Studio Code on Windows using the Remote-SSH extension with password authentication enabled.

It also explains and resolves the common SSH error: REMOTE HOST IDENTIFICATION HAS CHANGED

Architecture

Windows 10/11
 └─ Visual Studio Code
     └─ Remote-SSH Extension
         └─ OpenSSH (Windows)
             └─ Ubuntu Server (AWS Lightsail)
    

Prerequisites

  • Windows 10 or 11
  • Visual Studio Code (v1.108+)
  • Remote - SSH extension
  • Ubuntu server (AWS Lightsail)
  • Administrator access on Ubuntu

Enable Password Authentication on Ubuntu

AWS Lightsail disables password authentication by default for security.
Step 1: Initial Login Using SSH Key
ssh -i lightsail.pem ubuntu<PUBLIC_IP>
Step 2: Set Password
sudo passwd ubuntu
Step 3: Enable Password Authentication
sudo nano /etc/ssh/sshd_config

Ensure the following settings:

PasswordAuthentication yes
UsePAM yes
Restart SSH Service
sudo systemctl restart ssh

Connecting via VS Code Remote-SSH

Install Extension

Install Remote - SSH from the VS Code marketplace.

Add SSH Host
ssh ubuntu<SERVER_IP>

Save configuration to: C:\Users\<USERNAME>\.ssh\config

Common Error: Host Key Verification Failed

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Host key verification failed.
Offending ECDSA key in C:\Users\<USER>\.ssh\known_hosts

Root Cause

SSH stores a fingerprint for every host it connects to. If the server is reinstalled, recreated, or its IP reused, the fingerprint changes and SSH blocks the connection to prevent man-in-the-middle attacks.

Resolution

Recommended (Automatic)
ssh-keygen -R <SERVER_IP>
Manual Alternative
  1. Open C:\Users\<USER>\.ssh\known_hosts
  2. Delete the line matching the server IP
  3. Save the file

Reconnect and confirm the new fingerprint by typing yes.

Networking Note

IPs in 192.168.x.x, 10.x.x.x, or 172.16–31.x.x are private.

For AWS Lightsail access from home networks, always use the Public IPv4 address.

Security Considerations

  • Password SSH is less secure than key-based SSH
  • Use strong passwords
  • Restrict SSH access in Lightsail firewall
  • Prefer key-based authentication for production

Documentation • VS Code Remote SSH • Ubuntu • AWS Lightsail

VS Code Remote SSH with Ubuntu Lightsail

Connecting Ubuntu (AWS Lightsail) to VS Code

Remote SSH Setup • Key Authentication • PuTTY • Host Key Fix

Overview

This guide explains how to connect an Ubuntu AWS Lightsail server to Visual Studio Code (Windows) using the Remote-SSH extension.

Host Key Errors Resolved Key-Based Authentication

Architecture

Windows 10/11
 └─ VS Code
     └─ Remote-SSH
         └─ OpenSSH
             └─ Ubuntu (Lightsail)

Prerequisites

  • ✔ Windows 10 / 11
  • ✔ Visual Studio Code
  • ✔ Remote - SSH Extension
  • ✔ Ubuntu Lightsail Instance
  • ✔ Downloaded .pem Key

Generate .PPK from .PEM (PuTTY Users)

PuTTY requires a .ppk key file instead of .pem.
  1. Open PuTTYgen
  2. Click Load
  3. Select your lightsail.pem
  4. Click Save private key
  5. Save as lightsail.ppk
Connect in PuTTY
  1. Enter server Public IP
  2. Go to Connection → SSH → Auth
  3. Select the .ppk file
  4. Click Open
Login as: ubuntu

Recommended: Use .PEM Directly in VS Code

Move key to:
C:\Users\\.ssh\
Host lightsail
  HostName 
  User ubuntu
  IdentityFile C:\Users\\.ssh\lightsail.pem

Then in VS Code:

Remote-SSH: Connect to Host → lightsail

Fix: REMOTE HOST IDENTIFICATION HAS CHANGED

Host key verification failed error
ssh-keygen -R 

Reconnect and type yes to trust the new fingerprint.

Security Best Practices

  • ✔ Prefer key-based authentication
  • ✔ Restrict SSH to your IP in Lightsail firewall
  • ✔ Avoid enabling password login in production
  • ✔ Keep private keys secure

VS Code Remote SSH • Ubuntu • AWS Lightsail • 2026