Editing Files Remotely Via SSH On SublimeText 3
Editing Files Remotely Via SSH On SublimeText 3
Editing Files Remotely Via SSH On SublimeText 3
Sometimes you need to edit a file on a remote server, but using vim/emacs is not very practical, due to lag
and speed of screen refresh.
TextMate users have the classic rmate, but it was implemented in Ruby, which may not be available on the
remote server.
A better option is to use this version of rmate, implemented in pure Bash. It's a single file, self-contained, and
with no external dependencies.
Step by step:
1. (on your local workstation) On Sublime Text 3, open Package Manager (Ctrl-Shift-P on Linux/Win,
Cmd-Shift-P on Mac, Install Package), and search for rsub
2. (on your local workstation) Add RemoteForward 52698 127.0.0.1:52698 to your .ssh/config file, or -R
52698:localhost:52698 if you prefer command line
3. On your remote server:
Just keep your ST3 editor open, and you can easily edit remote files with rsub myfile.txt.
EDIT: if you get "no such file or directory", it's because your /usr/local/bin is not in your PATH. Just add
the directory to your path:
Now just log off, log back in, and you'll be all set.
34 Comments wrgms.com
1 Login
Sort by Newest
Recommend 14 Share
LOG IN WITH
Name
Hopefully that works. When you try on the server to do rsub file.txt and it doesn't work, ensure
that Sublime is already running on your workstation. Running rsub will not open sublime locally.
Reply Share
and if I run the rsub command directly from the directory it was saved, I also get
the same error.
Reply Share
means, the file is there. Again, if I run directly from /usr/local/bin/ the
command : rsub test - I get the same error message!
even when I just run: /usr/local/bin/rsub-- I get:
: No such file or directory
Reply Share
What comes *before* "root 9256"? You didn't copy the most important part,
with the file permissions...
That's likely what's missing. It should be -rwxr-xr-x. To fix, use "chmod a+x
/usr/local/bin/rsub"
Reply Share
It seems your rsub is in the right path, and has right permissions (777 - a
bit too permissive, as anyone can write, but ok, wouldn't cause problems).
So the problem must be when executing rsub.
Reply Share
ah, that explains everything. In this case, you have quite a bit of homework
to do, to change the script to run with Cygwin under Windows.
You may try replacing the first line by /bin/bash and giving it a shot. It might
work.
Reply Share
You likely did not add the RemoteForward to your ".ssh/config" (step 2). Optionally, you
can append "-R 52698:localhost:52698" to your ssh command when connecting to the
remote machine, so establish the forward on port 52698.
Reply Share
```
sudo wget -O /usr/local/bin/subl https://raw.github.com/auro...
chmod a+x /usr/local/bin/subl
```
1 Reply Share
2 years ago
Hey guys,
It didn't really work for me either, but you have to follow the following instructions to make it
work:
If you have multiple servers you want this to work for, do the following as exactly shown here:
Host *
RemoteForward 52698 localhost:52698
Also, make sure your sublime text console says the following:
This did the trick for me, I hope it helps some hapless stranger as well!
https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/ 4/7
19/08/2017 Editing files remotely via SSH on SublimeText 3
This did the trick for me, I hope it helps some hapless stranger as well!
Reply Share
Currently getting the error as follows after I ssh to the remote server. I ssh using `ssh -R
52968:localhost:52968 yourservername.com` as per your comments @Gui Ambros.
```bash
root@Dev:~# rsub test.txt
/usr/local/bin/rsub: connect: Connection refused
/usr/local/bin/rsub: line 322: /dev/tcp/localhost/52698: Connection refused
Unable to connect to TextMate on localhost:52698
```
Any ideas?
EDIT
My issue is I had already had a block in my SSH config for connecting to this remote server. I
adjusted my block to look like:
see more
1 Reply Share
1 Reply Share
The 'rsub' command just edits a file on my local machine. I don't understand how other people in
the comments had success with this. It just doesn't work.
Reply Share
If you installed rsub extension, and added the RemoteForward to your .ssh_config, the
expected behavior is to type 'rsub myfile.txt' on the remote server, and it'll open in
Sublime on your local machine.
If it doesn't work, confirm that you really added RemoteForward, and check the ssh log
by using 'ssh -vv ...'
Reply Share
2) When I do run the Command Palette (which is what those keys are supposed to be mapped
to) there is no rsub.
Thanks
Mike
Reply Share
https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/ 6/7
19/08/2017 Editing files remotely via SSH on SublimeText 3
ALSO ON WRGMS.COM
AvatarGisele Pereira Funny. I left Wunderman in AvatarGui Ambros (Sorry for the delay; I guess you
July and started at Nokia in August... and so did must have solved it by now).Yes, on 2012/12/27
you! Almost.So we've got work anniversaries the password would be really c12-1b03. I
Written by
Gui Ambros
Maker, developer, ad:tech executive. Incurable optimist. Head of Operations & Technology @
WPP/Wunderman. I was there when the web was born. @GuiAmbros
https://wrgms.com/editing-files-remotely-via-ssh-on-sublimetext-3/ 7/7