Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Setup Sublime Text sFTP for Remote Development - DesignLinux

Sep 02 2020
designlinux 0 Comments

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 PACKAGE → SFTP.

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 folder → SFTP/FTP → Map 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 PREFERENCES → PACKAGE SETTINGS → SFTP → KEY 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 PREFERENCES → PACKAGE SETTINGS → SFTP → KEY BINDINGS → USER.

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.

Related

Tags: Sublime Code Editor

How to Install Atom Text Editor on Ubuntu 20.04

Prev Post

How to Fix “Shared connection to x.x.xx closed” Ansible Error

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 257
  • 614,629

DesignLinux.com © All rights reserved

Go to mobile version