Sync Local Files with Remote Server in VSCode

You can perform local and remote syncronization in Visual Studio Code (VSCode).

Prerequisites

  • Local installation of VSCode

  • SSH connection to a remote server

Install VSCode SFTP extension

You need to install and configure in VSCode, the plugin that provide SFTP (Secure File Transfer Protocol) functionality.

Here’s a general outline of how you might work with the SFTP extension:

  1. Install the SFTP Extension:

  • Open VSCode.

  • Go to the Extensions view (see Fig. 1) by clicking on the Extensions icon in the Activity Bar on the side of the window or using the keyboard shortcut Ctrl+Shift+X.

  • Search for “sftp” and install the “SFTP” extension provided by Natizyskunk

Alternative text

Fig 1. Screenshot Extensions view of VSCode

  1. Configure the SFTP settings for your project:

  • After installation, open the project containing your python scripts on VScode.

  • Open the command palette by pressing F1 or Press Cmd+Shift+P (Mac),

  • Type SFTP and select “SFTP:config”. This will create a sftp.json file inside your project (Fig. 2). This will contain the settings of your sftp connection for your specific project.

  • Fill in the config details (like hostname, username, password), usually the default config fields is enough, and you just need to change the values.

  • Then save your changes.

Alternative text

Fig 2. Screenshot of the sftp.json configuration file

  1. Synchronize files between local and remote server

  • After you’ve saved your configs, the SFTP icon on the side-bar should pop up AND when you press Ctrl+Shift+P OR F1 you’ll have access to a whole host of option

  • the 3 options (Sync Local -> Remote, Sync Remote -> Local Sync both direction) is what you need.

  • Now we check that the files have been synced to the remote server:

Alternative text

Fig 2. Screenshot of the SFTP commands to synchronize files between your local machine and the remote server

Please check the official documentation for the specific SFTP extension you are using for detailed usage instructions and configuration options