Originally posted on the DAIS Lab blog.

Command line-based text editors like vim and Emacs have a steep learning curve and even simple tasks like navigating around in the interface isn’t always straightforward for beginners. In this tutorial, we’ll show you how to edit files on a remote server like Compute Canada in an intuitive and easy manner using Sublime Text 3 and SFTP.

Set Up

  1. First, download Sublime Text 3.

  2. Then install the Package Control plugin using the instructions on the page.

  3. Once Package Control is installed, restart Sublime Text then press Ctrl+Shift+P to open the Command Palette. Type Install and select Package Control: Install Package. Type in SFTP and press Enter to install the SFTP package.

Select Your Folder

First, you’ll have to select and open a folder that you want to sync with the remote server. You can create a new folder if you’re starting from scratch, then go to File > Open Folder in Sublime Text to open that folder. Right click on the folder that you’ve just selected and you should see a SFTP/FTP and Map to Remote option in the context menu.

Clicking on Map to Remote creates a sftp-config.json file to save your settings which looks something like this:

    // The tab key will cycle through the settings when first created
    // Visit http://wbond.net/sublime_packages/sftp/settings for help
    // sftp, ftp or ftps
    "type": "sftp",

    "save_before_upload": true,
    "upload_on_save": true,
    "sync_down_on_open": false,
    "sync_skip_deletes": false,
    "sync_same_age": true,
    "confirm_downloads": false,
    "confirm_sync": true,
    "confirm_overwrite_newer": false,
    "host": "",
    "user": "ubuntu",
    "port": "22",
    "remote_path": "/home/ubuntu/wlr/",
    "ignore_regexes": [
        "\\.sublime-(project|workspace)", "sftp-config(-alt\\d?)?\\.json",
        "sftp-settings\\.json", "/venv/", "\\.svn/", "\\.hg/", "\\.git/",
        "\\.bzr", "_darcs", "CVS", "\\.DS_Store", "Thumbs\\.db", "desktop\\.ini"
    "connect_timeout": 30

Settings Configuration

There are several important parameters that you need to fill in for SFTP to work:

  • host
  • user
  • port
  • remote_path

If you’re following our Compute Canada Cloud tutorial, host is the floating IP adress that you get from the Compute Canada config page. user would be ubuntu and port is 22. Otherwise, please use the settings for your server.

remote_path refers to the path on the remote server where the files will be synced. The path must exist on the server for this to work. For example, if you want to sync /home/mycomputer/dais/ on your own computer to /home/ubuntu/dais on the remote server, you will need to first create the dais folder on the remote server. This is easy, just SSH into the server (as explained in the Compute Canada Cloud setup tutorial) and use mkdir dais to create a directory called dais.

I usually leave the other settings on their default value, except upload_on_save, which I set to true. Setting it to true will ask SFTP to automatically upload the file to the server everytime you save it on your computer.

Running Your Program

My workflow is simple. I write my code in Sublime Text 3 and use SFTP to automatically sync it to the Compute Canada server whenever I save the file. I would then SSH into the server and then run my program from the terminal. For example, if I have a python file called main.py, I would edit and sync the file then SSH into the server and run python main.py.

Syncing Remote Files To Your Computer

If you have a program that dumps some output on the server, you can (very conveniently) grab the files to your computer using the Sync Remote to Local command or Download Folder command. For example, if your results are dumped into a folder called output, simply right click on that folder in Sublime Text then select Download Folder to download the entire folder, or Sync Remote to Local to only grab files that you don’t have on your computer.

Final Notes

To save yourself some time and mouse clicks, check out the SFTP page and learn the shortcuts for uploading/downloading files: https://wbond.net/sublime_packages/sftp/usage