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
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
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
- Open
C:\Users\<USER>\.ssh\known_hosts - Delete the line matching the server IP
- Save the file
Reconnect and confirm the new fingerprint by typing
yes.
Networking Note
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
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 AuthenticationArchitecture
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)
- Open PuTTYgen
- Click Load
- Select your
lightsail.pem - Click Save private key
- Save as
lightsail.ppk
Connect in PuTTY
- Enter server Public IP
- Go to Connection → SSH → Auth
- Select the
.ppkfile - Click Open
Login as: ubuntu
Recommended: Use .PEM Directly in VS Code
Move key to: C:\Users\\.ssh\
Host lightsail HostNameUser ubuntu IdentityFile C:\Users\ \.ssh\lightsail.pem
Then in VS Code:
Remote-SSH: Connect to Host → lightsail
Fix: REMOTE HOST IDENTIFICATION HAS CHANGED
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
