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

Listen to this Post. Powered by iSpeech.org

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 user@remote.com
  3. Download Rmate: curl https://raw.github.com/aurora/rmate/master/rmate > 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 user@remote.com
  3. Rmate the file you want to edit locally: rmate file.php
  4. The file should open in ST2 in your computer.

4 comments

  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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Anti-spambot Quiz:

Notify me of followup comments via e-mail. You can also subscribe without commenting.