Remote SFTP/FTP File Editing for VS Code
vscode-sftp
forked from Natizyskunk/vscode-sftp
This is a fork of the VS Code SFTP extension. It contains modifications and fixes for my own development workflow.
The original project was itself forked from liximomo/vscode-sftp.
VSCode-SFTP enables you to edit remote files via SFTP or FTP.
It provides a familiar workflow for working with remote files directly from VS Code.
Configuration
The extension is configured using a sftp.json file inside the .vscode directory of your workspace.
Create the configuration with:
SFTP: config
A basic configuration looks like this:
{
"name": "My Server",
"host": "example.com",
"protocol": "sftp",
"port": 22,
"username": "username",
"remotePath": "/var/www/project",
"uploadOnSave": true
}
Common Configuration Options
| Option |
Description |
name |
Name of the configuration |
host |
Remote server hostname or IP address |
protocol |
Connection protocol: sftp, ftp or local |
port |
Remote server port |
username |
Username used for authentication |
password |
Password used for authentication |
privateKeyPath |
Path to an SSH private key |
remotePath |
Remote directory to synchronize |
uploadOnSave |
Upload the file automatically after saving |
downloadOnOpen |
Download a file when it is opened |
useTempFile |
Use a temporary file during transfers |
ignore |
Files or directories to exclude |
ignoreFile |
Path to an ignore file |
watcher |
Configuration for automatic file watching |
profiles |
Define multiple connection profiles |
defaultProfile |
Profile selected by default |
Upload on Save
To automatically upload files after saving:
{
"host": "example.com",
"username": "username",
"remotePath": "/var/www/project",
"uploadOnSave": true
}
File Watcher
The File Watcher can automatically upload changed files and remove deleted files from the remote server.
{
"host": "example.com",
"username": "username",
"remotePath": "/var/www/project",
"watcher": {
"files": "**/*",
"autoUpload": true,
"autoDelete": true
}
}
The watcher is optional.
Profiles
Profiles allow multiple server configurations to be stored in one sftp.json:
{
"username": "username",
"remotePath": "/var/www/project",
"profiles": {
"development": {
"host": "dev.example.com",
"remotePath": "/var/www/dev",
"uploadOnSave": true
},
"production": {
"host": "prod.example.com",
"remotePath": "/var/www/prod",
"uploadOnSave": false
}
},
"defaultProfile": "development"
}
Use:
SFTP: Set Profile
to switch between profiles.
Temporary Files
The extension uses a temporary local directory for each remote connection.
The directory is created automatically based on the connection configuration.
On macOS and Linux, the files are stored under:
~/.sftp/tmp/<hash>/
On Windows, the corresponding directory is located under the user's home directory:
%USERPROFILE%\.sftp\tmp\<hash>\
The <hash> is generated from the following connection settings:
protocol
host
port
username
remotePath
This ensures that different remote configurations use separate local directories.
The temporary directory does not need to be configured manually.
Important: context
The context configuration option from the original extension has been removed from this fork.
The local base directory is determined automatically from the VS Code workspace and the SFTP configuration.
Therefore, existing configurations containing:
"context": "some/path"
should remove this option.
For example, use:
{
"host": "example.com",
"username": "username",
"remotePath": "/var/www/project"
}
instead of:
{
"context": "project",
"host": "example.com",
"username": "username",
"remotePath": "/var/www/project"
}
Remote Explorer
The Remote Explorer uses the workspace and the configured remotePath to determine the corresponding remote location.
No context setting is required.
Original Project
This fork is based on:
Natizyskunk/vscode-sftp
The Natizyskunk project was itself forked from:
liximomo/vscode-sftp
This fork is maintained primarily for my personal development workflow.
License
This project is based on the original liximomo/vscode-sftp project.
See LICENSE for the applicable license.