Editing Files on a Remote Server using Sublime

By Tony Sui, Mon 03 April 2017, in category General

Linux, Servers, Sublime

  
@

Not a Vim or Nano master, or just can’t get a hang of the HJKL? Had enough of SCP-ing or WinSCP-ing files to local?

Look no further; whether you access your servers through PuTTY on Windows, or SSH on Linux / OS X, this tutorial will walk you through step by step on how to edit files on a remote server using your locally installed Sublime editor.

Note that you will need to have sudo privileges while going through this tutorial. I know it’s fun, but try not to play with rm –rf... Unprivileged users can gain root access - WORLD WILL END! (Ben Carley, 2017)

Come and Meet Your New Best Friend, rsub

To install the rsub package on Sublime:

Voilà, your new best friend has been installed.

Tunneling with Windows / PuTTY

img

Tunneling with Linux / OS X

Open your CLI / Terminal, and create (if you don't have one) and edit the config file in the .ssh folder:

vim ~/.ssh/config

Enter your server details. For example, if you were trying to log in to an AWS EC2 instance, where your Public DNS was ec2-12-123-123-12.eu-west-1.compute.amazonaws.com, and your private was located at ~/.ssh/my_aws.pem, you would want to write the following:

Host aws
Hostname ec2-12-123-123-12.eu-west-1.compute.amazonaws.com
User ec2-user
IdentityFile ~/.ssh/my_aws.pem
RemoteForward 52698 127.0.0.1:52698

Installing rmate on Your Remote Server

Now log in to your remote server and run the following command, in order to install rsub’s best friend, rmate

sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate
sudo chmod +x /usr/local/bin/rsub

Now, rsub and rmate can talk to each other through the tunnel. Try it out!

rsub my_file_on_the_server.py