Mounting a Remote Server in VS Code with SSH FS
The SSH FS extension mounts a remote directory as a workspace folder over SFTP, so you edit remote files with local VS Code.
Note: You will need to replace SITE_USERNAME and PATH_TO_PRIVATE_KEY with your details!
1. Install the extension
code --install-extension Kelvin.vscode-sshfs
2. Write the configuration
Configuration lives in settings.json under the sshfs.configs array. Writing it
to the workspace file keeps it next to your project and avoids clobbering your
personal settings.
Note: This is editing a json file located at ~/.vscode/settings.json. You could edit the file directly, but copypasting the snippets below should get the job done quickly.
Linux / macOS
mkdir -p .vscode && cat > .vscode/settings.json <<'JSON'
{
"sshfs.configs": [
{
"name": "cse365",
"label": "CSE 365 Server",
"host": "cse365.robwaz.net",
"port": 2223,
"username": "SITE_USERNAME",
"privateKeyPath": "PATH_TO_PRIVATE_KEY",
"root": "/home/SITE_USERNAME"
}
]
}
JSON
Windows (PowerShell)
New-Item -ItemType Directory -Force .vscode | Out-Null
@'
{
"sshfs.configs": [
{
"name": "cse365",
"label": "CSE 365 Server",
"host": "cse365.robwaz.net",
"port": 2223,
"username": "SITE_USERNAME",
"privateKeyPath": "PATH_TO_PRIVATE_KEY",
"root": "/home/SITE_USERNAME"
}
]
}
'@ | Set-Content -Encoding utf8 .vscode\settings.json
If .vscode/settings.json already exists, these commands overwrite it — paste
the sshfs.configs key into the existing object instead.
3. Connect
There should now be a folder looking icon on the left sidebar of your VSCode window near the bottom. Selecting it will show "configurations" and "connections". Hovering your mouse over the cse365 configuration will reveal several small icons. The folder icon will mount the challenge environment into your VSCode explorer. The terminal icon will open a terminal inside VSCode that is connected to the challenge instances.