Skip to content

Instantly share code, notes, and snippets.

@zubaer-ahammed
Last active April 25, 2024 09:45
Show Gist options
  • Save zubaer-ahammed/c281e52fcc43c123f2e90af0597cd199 to your computer and use it in GitHub Desktop.
Save zubaer-ahammed/c281e52fcc43c123f2e90af0597cd199 to your computer and use it in GitHub Desktop.
Open Remote File in Sublime Text (Linux Server) - Tested with Ubuntu

Open Remote File in Sublime Text:

I felt the importance of directly editing a file from a DigitalOcean droplet on my Ubuntu Server. I research on the internet and made a way to do it.

Local Machine Settings:

  1. Install "rsub" in your Sublime Text.

    • Hit Ctrl+Shift+P, start typing “install” and select “Install Package”
    • Start typing “rsub” and select it.
  2. nano ~/.ssh/config and paste the following lines:

    Host remoteHost
        	RemoteForward 52698 localhost:52698
    

    In my case my host is: [email protected]

    So, I have put the following in my ~/.ssh/config file

     Host [email protected]
         RemoteForward 52698 localhost:52698
    

Remote Server Settings:

  1. Install the rsub script: sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate

  2. Make it executable: sudo chmod +x /usr/local/bin/rsub

  3. Now, you are ready to open any file by typing "rsub" before it. Example: sudo rsub info.php

*Final Step:

Directly ssh into remote server with rsub enabled: ssh -R 52698:localhost:52698 [email protected]

⚠️ Troubleshooting if it says Unable to connect to TextMate on localhost:52698:

http://stackoverflow.com/questions/18938950/rsub-with-sublime-and-ssh-connection-refusual
@zarmstrong
Copy link

To make life easier for me to copy/paste this when I need it:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment