Skip to content

Instantly share code, notes, and snippets.

@Ninjex Ninjex/rsub-doc.md
Last active Apr 6, 2018

Embed
What would you like to do?
How to: Setting up Sublime Text to work through an SSH tunnel.

First, you need to install the Sublime Text package manager.

To do this, open up Sublime Text, and hit hit the cntrl+p key binding (or navigate to: Preferences -> Package Control)

When prompted for the search query, type the following: 'Package Control: Install Package'

Press enter, and shortly it should generate a list of plugins that can be installed to Sublime.

Search for the following plugin: 'RemoteOpen' and press enter. This will begin the installation.

Next, we need to configure some settings in our ~/.ssh/config file, so go ahead and open up your favorite editor (Hopefully Sublime) and add the following code:

Host <hostname / host ip here>
  RemoteForward 52698 127.0.0.1:52698

When we create a tunnel via ssh to our desired Host, it will start a session on port 52698, which is what Sublime Text will be waiting on.

This port can be configured from: Preferences -> Package Settings -> rsub -> Settings -- Default, however it is suggested not to do this.

Once you have all the above set up, tunnel into the remote machine you configured previously inside your ~/.ssh/config file.

We now want to install the remote rsub script, and configure it to be executable. The following code snippet will do this for you: sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate && chmod +x /usr/local/bin/rsub

Note that if you changed the port in the plugin settings, you need to change the port in the remote script.

Look for line number 56, which will look like port=52698 simply change it to your desired port.

Now, it's as simple as calling the rsub command on a file while on the machine.

Let's test it out with the following code that will generate a file with the text 'Hello, rsub!' and open it inside Sublime on your local machine.

echo 'Hello, rsub!' > tmp.txt && rsub tmp.txt

@meteabogdan

This comment has been minimized.

Copy link

meteabogdan commented Apr 6, 2018

Hi, is it possible to do this for UDP connections?
I'm using mosh to connect to my ec2 instance so I can roam between ips and different connections without getting a broken pipe. However, rsub gives me this:
usr/local/bin/rsub: connect: Connection refused /usr/local/bin/rsub: line 390: /dev/tcp/localhost/52698: Connection refused Unable to connect to TextMate on localhost:52698

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.