Remote Edit Files Using VS Code SSH | Generated by AI
Question: How to use VS Code to remotely edit files on a server?
Answer:
The best and most popular way to remotely edit files on a server using Visual Studio Code is the official Remote - SSH extension. It gives you a full VS Code experience on the remote machine (IntelliSense, debugging, terminal, extensions, etc.).
Step-by-step guide (2025–2026 method)
- Prerequisites
- VS Code installed on your local computer
- SSH server running on the remote machine (almost all Linux servers have it)
- You can already connect via terminal using
ssh user@server-ip(very important to test first!)
- Install the Remote - SSH extension
- Open VS Code
- Go to Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon Mac) - Search for Remote - SSH
- Install the one published by Microsoft (ms-vscode-remote.remote-ssh)
-
(Recommended) Set up SSH key authentication Password login works, but keys are much more convenient and secure.
On your local machine:
ssh-keygen -t ed25519 -C "your_email@example.com" # Press Enter to accept default location & no passphrase (or set one)Copy public key to server (easiest way):
ssh-copy-id user@your-server-ipOr manually:
cat ~/.ssh/id_ed25519.pub # copy output → paste into server's ~/.ssh/authorized_keys -
Configure SSH connection in VS Code Two main ways:
Way A – Quick (recommended for most people)
- Press
Ctrl+Shift+P→ type Remote-SSH: Connect to Host… - Select Add New SSH Host…
- Enter:
ssh user@server-ip -p 22(or justuser@server-ipif port 22) - Choose config file location (usually
~/.ssh/configon Linux/Mac or%USERPROFILE%\.ssh\configon Windows) -
VS Code adds an entry like this:
Host my-server HostName 192.168.1.150 # or domain.com User yourusername Port 22 # Optional: IdentityFile ~/.ssh/id_ed25519
Way B – Manual edit (more control)
Open/create file
~/.ssh/configand add:Host myserver HostName 123.45.67.89 User devuser Port 2222 # only if not default 22 IdentityFile ~/.ssh/id_ed25519 - Press
- Connect
Ctrl+Shift+P→ Remote-SSH: Connect to Host…- Select your host (e.g.
myserveroruser@ip) - First time: VS Code installs its server component on the remote machine (~/.vscode-server)
- Wait 30–90 seconds (only first time)
- Open folder and start editing
- After connection → you see green bar at bottom left (“SSH: myserver”)
File → Open Folder...→ browse remote filesystem → select project folder- Or drag folder from Remote Explorer sidebar
- Now edit files normally — save = saved directly on server
- Useful features once connected
- Integrated terminal (
Ctrl+`) → runs on server - Install extensions remotely (look for “Install in SSH” button)
- Debugging, Git, tasks.json, etc. all work on remote
- Multiple hosts → use Remote Explorer sidebar
- Integrated terminal (
Quick Troubleshooting Tips
- Connection fails? → Test
ssh user@serverin terminal first - Very slow? → Check network, or add to
settings.json:"remote.SSH.useLocalServer": true, "remote.SSH.connectTimeout": 60 - Permission denied? → Fix SSH keys or password
- VS Code server install fails? → Server needs ~150–300 MB disk space + internet (to download once)
Alternative (if you cannot install anything on server)
Use SSH FS extension — it mounts remote folder via SFTP/SSHFS. Less powerful (no full remote extensions/debugging), but zero installation on server.
References: