How to Edit a Remote File over SSH Using Sublime Text and Rmate

Listen to this Post. Powered by

I wanted to be able to edit a file in my computer but have it save on the remote server.

That’s when I found the rsub plugin for Sublime Text 2 and rmate.

What does Rmate do?

Rmate is a script that you install on the remote server – the server you want to edit files from. It was originally created for Textmate.

Basically, what it does is when you run this script on a file, it sort of *pushes* that file from the remote server down to your computer where your text editor – Sublime Text or Textmate – is waiting to *catch* it. Well, that’s the for dummies (like me) explanation. Technically, we use an SSH tunnel or something.

What does Rsub do?

Rsub is a plugin that you install on Sublime Text 2. This is the thing allows ST2 to *catch* the file *pushed* down from the server and edit the file.

Installation and Setup

  1. Install rsub plugin for ST2.
  2. SSH to your remote machine: ssh
  3. Download Rmate: curl > rmate
  4. Move Rmate to bin: sudo mv rmate /usr/local/bin so don’t need to specify the path to rmate script
  5. Make it executable: sudo chmod +x /usr/local/bin/rmate
  6. Done!

How to use

  1. Run Sublime Text 2 in your computer.
  2. SSH to remote: ssh -R 52698:localhost:52698
  3. Rmate the file you want to edit locally: rmate file.php
  4. The file should open in ST2 in your computer.


  1. If you want something a bit more robust and editor-agnostic, you can try something I’ve been working on called xeno. It’s free and open source, and I’d love some feedback.

    Basically, it’s a Git/SSH mashup written in Python that allows you to edit files and folders from a remote machine in your local editor (whatever that may be). You don’t have to configure kernel modules or forward ports, you don’t need to have a persistent connection – it’s all automatic and easy.

    What it does is generate an out-of-worktree Git repository of the files you want to edit on the remote machine, and then clones it locally and uses Git over SSH as a transport/synchronization mechanism. Because it’s built on Git, it’s extremely fast and supports automatic merging of files that might be changing on both ends, unlike SSHFS/rmate/rsub which will just clobber any files with older timestamps.

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-spambot Quiz: