Categories
Uncategorized

Live Text Editing on a Remote Server using Rmate and Rsub

Update October 2022: VSCode Shell Extension is different option

What is a remote server?

A remote server is a computer in a datacenter somewhere accessible through the internet (not your local network).

Remote servers can be:

  • Database servers
  • Web servers
  • DNS (Domain Name Service) servers
  • Mail servers
  • Proxy servers
  • Application servers, and
  • Real-time Communication Servers (skype, VoIP)

How do you connect to and communicate with a Remote Server?

There are multiple ways:

  • FTP: File Transport Protocol, using a file transfer program such as FileZilla or WinSCP. You just need to setup the hostname (your server address) and enter your authentication details (username and password) and you will be able to transfer files from your local pc to the remote server.
  • Telnet: Is a protocol that allows for bidirectional (to and from server) text communication. Similar to command line and terminal to communicate with the remote host. Unfortunately Telnet does not encrypt data sent to and from the server. There is also no default authentication so this protocol has been rarely used based on it’s security flaws.
  • Secure Shell (SSH): Is a cryptographic network protocol that secures data communication, remote shell services and command line execution between computer. Common applications for windows is Putty but it is built in with Unix like operating systems as (Terminal).

Common Server Commands

Change Directory

cd foldername   //move into that directory
cd /foldername  //move into that directory which is one up from where we are
cd ..           //move to the directory one up from where we are

Show Directories

ls       //show directories and files
ls -la   //show directories and files with additional information

Editing A File

vim filename.txt       //edit a file with the in-built vim editor

There is however a limitation of vim:
Because it is run through command line, functionality such as: find and replace, use of cursor, copy, paste and other common features in text editors are missing.

So How can we Edit Text Live on the Server?

Well the Solution is:

Rmate or Rsub

  1. Install SublimeText or Textmate on your pc

(Sublimetext is for all OS’s, Textmate only Mac)

  1. SSH into your server

  2. Install Ruby Gems on the Server

  3. install rmate


gem install rmate
  1. update rmate

gem update rmate

  1. tell sublimetext or textmate to listen on port 52698
  2. use the following command to open the file in sublimetext or textmate from the server

ssh -R 52698:127.0.0.1:52698 user@example.org

rmate filename.txt

  1. you can now edit the file as you would a in a normal textfile, when you hit save it will save on the server.