Skip to content
Bradley Culbertson edited this page Jul 12, 2024 · 11 revisions

sftp+ Sync for VS Code

New maintained and updated version by @thebestbradley and @zekeduncan

Forked from Natizyskunk SFTP plugin This will enable us to add new features regularly and will contribute back to the main project. Natizyskun can then decide which features he would like to incorporate.


VSCode-SFTP enables you to add, edit or delete files within a local directory and have it sync to a remote server directory using different transfer protocols like FTP or SSH. The most basic setup requires only a few lines of configuration with a wide array of specific settings also available to meet the needs of any user. Both powerful and fast, it helps developers save time by allowing the use of a familiar editor and environment.

Original Repo Documentation

Original Wiki

You can see the full list of configuration options here.

Note: name is required in this mode.

Connection Hopping

You can connect to a target server through a proxy with ssh protocol.

Note: Variable substitution is not working in a hop configuration.

Single Hop

local -> hop -> target

{
  "name": "target",
  "remotePath": "/path/in/target",

  // hop
  "host": "hopHost",
  "username": "hopUsername",
  "privateKeyPath": "/Users/localUser/.ssh/id_rsa", // <-- The key file is assumed on the local.

  "hop": {
    // target
    "host": "targetHost",
    "username": "targetUsername",
    "privateKeyPath": "/Users/hopUser/.ssh/id_rsa", // <-- The key file is assumed on the hop.
  }
}

Multiple Hop

local -> hopa -> hopb -> target

{
  "name": "target",
  "remotePath": "/path/in/target",

  // hopa
  "host": "hopAHost",
  "username": "hopAUsername",
  "privateKeyPath": "/Users/hopAUsername/.ssh/id_rsa" // <-- The key file is assumed on the local.

  "hop": [
    // hopb
    {
      "host": "hopBHost",
      "username": "hopBUsername",
      "privateKeyPath": "/Users/hopaUser/.ssh/id_rsa" // <-- The key file is assumed on the hopa.
    },

    // target
    {
      "host": "targetHost",
      "username": "targetUsername",
      "privateKeyPath": "/Users/hopbUser/.ssh/id_rsa", // <-- The key file is assumed on the hopb.
    }
  ]
}

Configuration in User Setting

You can use remote to tell sftp to get the configuration from remote-fs.

In User Setting:

"remotefs.remote": {
  "dev": {
    "scheme": "sftp",
    "host": "host",
    "username": "username",
    "rootPath": "/path/to/somewhere"
  },
  "projectX": {
    "scheme": "sftp",
    "host": "host",
    "username": "username",
    "privateKeyPath": "/Users/xx/.ssh/id_rsa",
    "rootPath": "/home/foo/some/projectx"
  }
}

In sftp.json:

{
  "remote": "dev",
  "remotePath": "/home/xx/",
  "uploadOnSave": false,
  "ignore": [".vscode", ".git", ".DS_Store"]
}

Remote Explorer

remote-explorer-preview

Remote Explorer lets you explore files in remote. You can open Remote Explorer by:

  1. Run Command View: Show SFTP.
  2. Click SFTP view in Activity Bar.

You can only view a files content with Remote Explorer. Run command SFTP: Edit in Local to edit it in local.

Multiple Select

You are able to select multiple files/folders at once on the remote server to download and upload. You can do it simply by holding down Ctrl or Shift while selecting all desired files, just like on the regular explorer view.

Note: You need to manually refresh the parent folder after you delete a file if the explorer isn't correctly updated.

Order

You can order the remote Explorer by adding the remoteExplorer.order parameter inside your sftp.json config file.

In sftp.json:

{
  "remoteExplorer": {
    "order": 1 // <-- Default value is 0.
  }
}

Debug

  1. Open User Settings.
  • On Windows/Linux - File > Preferences > Settings
  • On macOS - Code > Preferences > Settings
  1. Set sftp.debug to true and reload vscode.
  2. View the logs in View > Output > sftp.

FAQ

You can see all the Frequently Asked Questions here.