How to Setup Sublime Text sFTP for Remote Development

This article is the second in a series about sublime text and how to set it up for remote development using the SFTP package. I suggest you refer to our previous article about the installation and configuration of sublime text 3.

Most of our development and deployment work will be happening in the remote server or cloud servers. In that case, we can use the sublime SFTP package to work with remote servers where we can push (Local to remote) or pull (Remote to Local) the codes/files using file transfer protocol. SFTP comes with a license cost but we can install the package and use it for an indefinite time.

Features of Sublime Text sFTP

  • FTP, SFTP, and FTPS protocols are supported.
  • Can either use password or SSH key-based authentication.
  • Sync folders – Locally, Remotely, and Bi-directionally.
  • Possible to sync only recently made changes.
  • The difference in local vs. remote versions of a file.
  • Persistent connections for good performance.

Installing sFTP on Sublime Text Editor

Assuming that you have installed and configured package control as described in the article, COMMAND PALLET [ CTRL + SHIFT + P ] → INSTALL PACKAGESFTP.

Install sFTP in Sublime Text
Install sFTP in Sublime Text

Now open COMMAND PALLET [ CTRL + SHIFT + P ]Type SFTP. You will find several options to work with SFTP functionalities. We will explore all of these options over the course of this article.

Sublime Text sFTP Options
Sublime Text sFTP Options

I have a directory where it contains two python scripts which will be Synced to a remote machine. My remote machine is Linux Mint 19.3 running on a VM. Now let’s configure the remote setup. Right-click on the project folderSFTP/FTPMap to Remote.

Configure Remote Setup for sFTP
Configure Remote Setup for sFTP

The sftp-config.json file will be created in the project folder which holds the remote configuration settings.

Remote Configuration Settings
Remote Configuration Settings

Let’s break down the settings and configure some important parameters. There are three different protocols (SFTP, FTP, and FTPS) can be used. Here we will use “SFTP”.

sFTP Protocol
sFTP Protocol

We will now configure remote host information like hostname, username, and port. Password will be prompted when we start the sync. The hostname can be FQDN or IP address and by default port number is 22.

Remote Host Settings
Remote Host Settings

SSH key-based authentication is also possible, we can create a Public-Private key pair and the key can be pointed to the location using the parameter “ssh_Key_file”.

SSH Authentication
SSH Authentication

Configure the remote directory path “remote_path” where the project files and folders need to be synced. We can also set file and directory permission using “file_permission” and “dir_permission” parameters. We can ignore files and folders to be synced by providing the file identifier in “ignore_regexes”.

Configure Remote Path
Configure Remote Path

We have done some mandatory configuration in sftp-config.json to start syncing our files to the remote machine. We have a few more options to configure depending upon the need. But as of now, these are the important parameters that we need to get going. Now in my remote machine, my directory /home/tecmint is empty. We will upload the project folder to /home/tecmint now.

Project Home Directory
Project Home Directory

Right-click on project folder → SFTP/FTP.

sFTP Operations
sFTP Operations

Sublime Text sFTP Operations and Usage

Let’s break down all the options.

Upload Folder

Will upload the local project folder to the remote directory configured in the sftp-config.json file. All the operations will be displayed at the bottom of the Sublime Text.

Upload Folder
Upload Folder

Both the files in the local directory are uploaded to the remote directory. The sftp-config.json files will be skipped.

Uploaded Files
Uploaded Files
Rename Local and Remote Folders

We can rename both remote and local directory at the same time by choosing rename local and remote folders options. It will prompt you to enter a new name at the bottom of ST.

Rename Folders
Rename Folders
Delete Local and Remote Folder

This option will delete the current project folder from both remote machine and local machine along with sftp-config.json file.

Local → Remote

Upload the files/folders to the remote machine. Difference between upload and sync is, sync will delete any extra files that are not in the local project folder. To demonstrate this I had created a file called “dummy.py” in my remote machine.

Now I try to sync the local → remote, it will prompt me with confirmation and the file dummy.py will be removed automatically.

Local to Remote
Local to Remote
Remote → Local

Sync remote files locally and remove any extra files in the local project folder.

Both Directions

Sync both directions will allow us to keep identical copies in both remote and local. It will be useful when we are making different changes to local as well as remote folders at the same time.

Browse Remote

We can access the remote files and folders other than the project directory using the browse remote option.

Browse Remote
Browse Remote
Multiple Remote Mapping

Now we have configured one remote host for syncing our project. It is also possible to create multiple remote mappings. Choose the “Alternate Remote Mapping” option which will create sftp-config-alt.json.

This is the same configuration file as the sftp-config.json file where we have to configure a second remote host. I have configured the second remote information and saved it. We can have multiple remote mapping configured.

Multiple Mapping
Multiple Mapping

We can now decide which remote mapping to choose from.

Switch Mapping
Switch Mapping

Select “Switch Remote Mapping…” option. It will prompt all the configured mapping to select from. Choose the mapping from the prompt and from the next operation, files and folder sync will be happening on the selected mapping.

Select Mapping
Select Mapping
Diff Remote File

We can check the difference between local and remote files using the “Diff Remote File” Option. I created a file dummy.py in the remote machine and added print(“Hello world”) but it is not synced locally. Now if I try to see the changes with a remote file it will print the changes I made.

Diff Remote File
Diff Remote File
Key Bindings

There are default key bindings we can use instead of hovering through the menus all the time. To know the list of key bindings PREFERENCESPACKAGE SETTINGSSFTPKEY BINDINGS DEFAULT.

We can also define our own set of key bindings which will override the default bindings. To create user-defined key bindings for SFTP PREFERENCESPACKAGE SETTINGSSFTPKEY BINDINGSUSER.

Key Bindings
Key Bindings

So far in this article, we have seen how to install the SFTP package to transfer files between local and remote machines through file transfer protocol. We have also seen how to upload/Sync folders from Local to remote and remote to local machines. Default keybindings and how to set user-defined key bindings.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.