I'm trying to use Sublime Text 2 as an editor when I SSH in to my work server, and I'm stumped. I found this http://urbangiraffe.com/2011/08/13/remote-editing-with-sublime-text-2/ (among many other posts) that looks like it might help, but I don't follow it exactly, particularly with what values I should put in for the remote variable in line 5. I set "/Users/path/to/local/copy" to my local root directory, but I don't know if that's right or if there's more to do. Any thoughts? I'm on OSX10.8
-
13I've found it easier to use [`osxfuse` and `sshfs`](http://osxfuse.github.io/) on my mac to locally mount remote directories and then edit via ST2. – AGS Apr 11 '13 at 23:53
-
There is a popular ST2 plugin for sftp. Here is a further explanation of a system to which I believe AGS is referring: http://superuser.com/questions/134140/mount-an-sshfs-via-macfuse-at-boot. I had a problem with auto-load on login, and had to use a workaround login script made with Platypus. I also needed a better version of macfuse -- I'll see if I can find the link if you are interested. – lawlist Apr 12 '13 at 02:27
-
With Snow Leopard (10.6.8), I needed an updated core for MacFuse (i.e., macfuse-core-10.5-2.1.9.dmg) -- here is the link to where I got it: http://blog.urbaninsight.com/2011/04/18/fixing-macfuse-latest-os-x-kernel If you are interested, that should save you a lot of headaches. – lawlist Apr 12 '13 at 02:37
-
1It wouldn't be live, and maybe less suitable for watching log files and stuff, but often setting up gitolite can be worth it. Just git pull and you have everything local to play with. Then again alot of people have fast internet these days and wouldn't feel the netwok lag... It all depends on your setup. – Apr 21 '14 at 22:36
-
Related: [Work on a remote project with Eclipse via SSH](https://stackoverflow.com/q/4216822/4561887). Some answers, [such as my own](https://stackoverflow.com/a/60315754/4561887), overlap, and work with _any_ text editor or IDE because I am simply syncing an entire repo via `git`. – Gabriel Staples Jan 18 '23 at 00:38
-
Looks like sshfs is not compatible with ARM Macs @AGS (I know your post was before their existence :D ) – volvox Jul 09 '23 at 06:07
15 Answers
There are three ways:
Use SFTP plugin (commercial) http://wbond.net/sublime_packages/sftp - I personally recommend this, as after settings public SSH keys with passphrase it is safe, easy and worth every penny http://opensourcehacker.com/2012/10/24/ssh-key-and-passwordless-login-basics-for-developers/
Mount the remote as local file system using
osxfuse
andsshfs
as mentioned in the comments. This might be little difficult, depending on OSX version and your skills with UNIX file systems.Hack together something like rmate which does file editing over remote tunneling using some kind of a local daemon (very difficult, cumbersome, but sudo compatible) http://blog.macromates.com/2011/mate-and-rmate/
Also, in theory, you can install X11 on the remote server and run Sublime there over VNC or X11 forwarding, but this would be very slow.

- 36,492
- 15
- 194
- 265

- 82,057
- 50
- 264
- 435
-
1See also related superuser.com question http://superuser.com/questions/581292/secure-remote-editing-of-root-accessible-files-over-ssh – Mikko Ohtamaa Apr 12 '13 at 07:52
-
11The SSHFS/osxfuse combo worked for me! Thanks. For others with this problem: https://github.com/osxfuse/osxfuse/wiki/SSHFS – thumbtackthief Apr 12 '13 at 15:55
-
can one with sftp plugin use tools like interactive shells and repl like in emacs? – Edmondo Jul 31 '13 at 07:32
-
-
I disagree with the "very difficult, cumbersome" comment; see below! – user456584 Aug 30 '13 at 17:39
-
1*Sublime SFTP* actually allows you either to edit files remotely but without the ST project pane (so **no** *Go to Anywhere*), or does something like a rsync. There is a free trial to test it. – Wernight Sep 20 '13 at 07:43
-
For more info on getting SFTP to work, see [Carl's answer](http://stackoverflow.com/a/19578692/35690) below. – Senseful May 02 '14 at 00:49
-
-
There is no need to "hack something together" when there is already a Sublime package that works like rmate, called [rsub](https://github.com/Drarok/rsub). See [ubik's answer](https://stackoverflow.com/a/18107549). – Sean the Bean Oct 30 '17 at 20:18
-
This package is a free alternative to SFTP: https://packagecontrol.io/packages/Rsync%20SSH – Pbinder Oct 25 '18 at 19:06
You can use rsub, which is inspired on TextMate's rmate
. From the description:
Rsub is an implementation of TextMate 2's 'rmate' feature for Sublime Text 2, allowing files to be edited on a remote server using SSH port forwarding / tunnelling.
Here's a good tutorial on how to set it up properly: (broken link) http://log.liminastudio.com/writing/tutorials/sublime-tunnel-of-love-how-to-edit-remote-files-with-sublime-text-via-an-ssh-tunnel

- 36,492
- 15
- 194
- 265

- 4,440
- 2
- 23
- 29
-
2I also agree that getting rsub to work is a snap, and allows sudo, which is great. I ran into some problems getting it to work right, but SO had the answer to that too: http://stackoverflow.com/questions/18938950/rsub-with-sublime-and-ssh-connection-refusual – Ross R Oct 18 '13 at 17:37
-
10please mark this answer instead of the first one since this is free – theodore hogberg Jan 24 '15 at 21:04
-
The guide worked perfectly, even for a total terminal noob like myself. Thanks! – Henrik Mar 21 '17 at 21:12
-
Thanks for sharing this! Now that I tried it, I cannot live without it!!! – Abramodj Oct 16 '20 at 10:18
-
4The link on the tutorial is dead and does the equivalent still exist for Sublime Text 3? It would be great if this answer could be updated. – Kvothe Feb 02 '21 at 18:39
-
Need to edit this answer to remove the link - leads to a deceptive/phishing site. – scp Jun 21 '22 at 16:57
I'm on Windows and have used 4 methods: SFTP, WinSCP, Unison and Sublime Text on Linux with X11 forwarding over SSH to Windows (yes you can do this without messy configs and using a free tool).
The fourth way is the best if you can install software on your Linux machine.
The fourth way:
MobaXterm
- Install MobaXterm on Windows
- SSH to your Linux box from MobaXterm
- On your linux box, install Sublime Text 3. Here's how to on Ubuntu
- At the command prompt, start sublime with
subl
- That's it! You now have sublime text running on Linux, but with its window running on your Windows desktop. This is possible because MobaXterm handles the X11 forwarding over SSH for you so you don't have to do anything funky to get it going. There might be a teeny amount of a delay, but your files will never be out of sync, because you're editing them right on the Linux machine.
Note: When invoking subl if it complains for a certain library - ensure you install them to successfully invoke sublimetext from mobaxterm.
If you can't install software on your Linux box, the best is Unison. Why?
- It's free
- It's fast
- It's reliable and doesn't care which editor you use
- You can create custom ignore lists
SFTP
Setup: Install the SFTP Sublime Text package. This package requires a license.
- Create a new folder
- Open it as a Sublime Text Project.
- In the sidebar, right click on the folder and select Map Remote.
- Edit the sftp-config.json file
- Right click the folder in step 1 select download.
- Work locally.
In the sftp-config, I usually set:
"upload_on_save": true,
"sync_down_on_open": true,
This, in addition to an SSH terminal to the machine gives me a fairly seamless remote editing experience.
WinSCP
- Install and run WinSCP
- Go to Preferences (Ctrl+Alt+P) and click on Transfer, then on Add. Name the preset.
- Set the transfer mode to binary (you don't want line conversions)
- Set file modification to "No change"
- Click the Edit button next to File Mask and setup your include and exclude files and folders (useful for when you have a .git/.svn folder present or you want to exclude build products from being synchronized).
- Click OK
- Connect to your remote server and navigate to the folder of interest
- Choose an empty folder on your local machine.
- Select your newly created Transfer settings preset.
- Finally, hit Ctrl+U (Commands > Keep remote directory up to date) and make sure "Synchronize on start" and "Update subdirectories" are checked.
From then on, WinSCP will keep your changes synchronized.
Work in the local folder using SublimeText. Just make sure that Sublime Text is set to guess the line endings from the file that is being edited.
Unison
I have found that if source tree is massive (around a few hundred MB with a deep hierarchy), then the WinSCP method described above might be a bit slow. You can get much better performance using Unison. The down side is that Unison is not automatic (you need to trigger it with a keypress) and requires a server component to be running on your linux machine. The up side is that the transfers are incredibly fast, it is very reliable and ignoring files, folders and extensions are incredibly easy to setup.
-
+1 for the `SFTP setup` link. I didn't know if SFTP was Windows software or a Sublime package. – Kevin Meredith Oct 01 '14 at 15:24
-
I use sftp for ST2, PuTTY, and a bit of FileZilla for good measure. It's the best setup I've found after trying many. I do, however, dislike having to keep a local fileset. I greatly prefer ST over terminal editors liek vi or nano - making ST3 on the server itself sounds like a sweet deal. thx for the tip - – Bosworth99 Oct 23 '14 at 02:22
-
If you're a cyberduck (https://cyberduck.io/?l=en) user, sublimetext integrates very well. – sakurashinken Aug 15 '15 at 00:06
As a follow up to @ubik's answer, here are the three simple (one-time) steps to get the 'subl' command working on your remote server:
[Local] Install the
rsub
package in Sublime Text using the Sublime Package Manager[Local] Execute the following Bash command (this will set up an SSH tunnel, which is rsub's secret sauce):
printf "Host *\n RemoteForward 52698 127.0.0.1:52698" >> ~/.ssh/config
[Server] Execute the following Bash command on your remote server (this will install the
subl
shell command):sudo wget -O /usr/local/bin/subl https://raw.github.com/aurora/rmate/master/rmate sudo chmod +x /usr/local/bin/subl
And voila! You're now using Sublime Text over SSH.
You can open an example file in Sublime Text from the server with something like subl ~/test.txt

- 36,492
- 15
- 194
- 265

- 86,427
- 15
- 75
- 107
-
1I keep getting: `/usr/local/bin/subl: connect: Connection refused /usr/local/bin/subl: line 200: /dev/tcp/localhost/52698: Connection refused Unable to connect to TextMate on localhost:52698`. Thoughts? – thumbtackthief Sep 30 '13 at 21:04
-
1Yes: add -R 52698:localhost:52698 to your ssh command. See here: http://stackoverflow.com/questions/18938950/rsub-with-sublime-and-ssh-connection-refusual – Ross R Oct 18 '13 at 17:39
-
Noob tip that I found useful: Remember to have Sublime running on your local machine. That actually starts the server. – Magne Oct 08 '14 at 08:19
-
@RossR - this does not work. Mine looks like this: "RemoteForward 52698 127.0.0.1:52698 -R 52698:localhost:52698" and still outputs same error: "Unable to connect to TextMate on localhost:52698" – FooBar Oct 15 '14 at 23:12
-
Hmmm - I'm not sure what's wrong. A few ideas: 1) on your local machine make sure 'subl file' works. 2) Add to .ssh/config: `Host *\n\tRemoteForward 52698 localhost:52698`; 3) Make sure when you log into your remote you don't see a warning about 'remote forwards disabled' - ssh will do that if your remote key differs from your known_hosts key and StrictHostChecking is no. Good luck! – Ross R Oct 16 '14 at 13:43
-
I guess this may only work for files and not an entire folder ? How do you work on complete projects on this? – pal4life Jul 21 '16 at 17:38
-
1the above works, u just need to restart the remote server afterward or u will keep getting the connection denied error. – ctf0 Aug 05 '16 at 14:16
-
-
rsub is no longer maintained - I use [RemoteSubl](https://github.com/randy3k/RemoteSubl) as its successor. See [this SO answer](https://stackoverflow.com/a/41931330/508355). – hashchange Apr 25 '20 at 14:01
I am on MacOS, and the most convenient way for me is to using CyberDuck, which is free (also available for Windows). You can connect to your remote SSH file system and edit your file using your local editor. What CyberDuck does is download the file to a temporary place on your local OS and open it with your editor. Once you save the file, CyberDuck automatically upload it to your remote system. It seems transparent as if you are editing your remote file using your local editor. The developers of Cyberduck also make MountainDuck for mounting remote files systems.
-
1i upvoted, although this does not work with sudo... (files that need superuser access to write) – Tiago Coelho Jul 29 '15 at 17:25
-
1Came to post this exact solution. As long as you are using CyberDuck, it is very convenient. However keep in mind that it only works while CyberDuck is running. You can also use the same method to open files in other editors but I have found that not all of them will work reliably and may lose connection or silently switch to saving locally only instead of remotely (e.g. Microsoft Excel). Never had a single problem with this using Sublime , though. – user5359531 Aug 08 '16 at 15:12
You can try something that I've been working on called 'xeno'. It will allow you to open up files/folders in Sublime Text (or any local editor really) over an SSH connection and automatically synchronize changes to the remote machine. It should work on almost all POSIX systems (I myself use it from OS X to connect to Linux machines and edit files in Sublime Text). It's free and open source. I'd love some feedback.
For more information: it's basically a Git/SSH mashup written in Python that allows you to edit files and folders on a remote machine in a local editor. You don't have to configure kernel modules, you don't need to have a persistent connection, it's all automatic, and it won't interfere with existing source control because it uses an out-of-worktree Git repository. Also, because it's built on Git, it's extremely fast and supports automatic merging of files that might be changing on both ends, unlike SSHFS/SFTP which will just clobber any files with older timestamps.

- 149
- 2
- 2
This is the easiest way to locally edit files which live on remote host where you have previously setup ssh to remote IP
# issue on local box
sudo apt-get install sshfs # on local host install sshfs ( linux )
# on local box create secure mount of remote directory
export REMOTE_IP=107.170.58.249 # remote host IP
sshfs myremoteuserid@${REMOTE_IP}:/your/remote/dir /your/local/dir # for example
Done !!!
Now on local host just start editing files ... when you list dir locally it may not list anything until you cd into subdir or list a specific file ... lazy loading ... this does not impact editing files
subl /your/local/dir/magnum_opus.go # local file edit using sublime text
so above is actually editing remote file at
/your/remote/dir/magnum_opus.go # remote file on box $REMOTE_IP
For OSX or Windows see this tut from the kind folk over on Digital Ocean

- 26,870
- 12
- 93
- 104
I know this is way old, but I have a really cool way of doing this that is worth sharing.
What is required in Conemu and WinSCP. These are simple instructions
Open WinSCP.exe and login to my desired remote server (I have
found that it's important to login before attaching ... ).In the preferences for WinSCP - two settings to change. Choose Explorer type interface and rather than Commander - so you don't see local files. Unless you want to (but that seems like it would suck here). Set up Sublime as your default editor.
With ConEmu open, right click the tab bar and select the option
Attach to...
. A dialog box will open with your running applications. Choose, WinSCP and select OK. ConEmu will now have an open tab with WinSCP displaying your remote files.Right click on the WinSCP tab and choose
New console...
. When the dialog box opens, enter the path to the Sublime executable on your system. Before you pressStart
, In the box that saysNew console split
select the radio buttonto right
and set the percentage. I usually choose 75%, but you can customize this to your liking, and it can be changed later.- Now you will see Sublime in the same window running to the right of WinSCP. In Sublime, from the View menu, choose
Sidebar->Hide Sidebar
, and bam, you now have remote files in exactly the same manner as you would locally - with a few caveats of course that comes with editing anything remotely. WinSCP is lightening fast though.
- Now you will see Sublime in the same window running to the right of WinSCP. In Sublime, from the View menu, choose
I have two monitors - left monitor display's Chrome browser, right monitor displays code editor. Also in ConEmu
, I create another tab and ssh into the site I'm working on, so I can do things like run gulp
or grunt
remotely and also manipulate files from the command line. Seriously sped up development.
Here's a screenshot:

- 188,800
- 56
- 490
- 992

- 3,877
- 5
- 34
- 47
You can use sftp to mount the remote directory on your location machine and then simply open the files using Sublime text the way you normally would.
To mount remote directory using sftp, enter the following on your Linux file manager;
sftp://user@remote_box.com:22/home/user/code_directory
It might seem slow depending on your internet speeds. But this worked for me.

- 7,352
- 2
- 36
- 29
Another mac solution similar to osxfuse is to just use Transmit FTP client from Panic Software, which allows you to mount a remote folder as a local disk. It supports SFTP, which is very secure.

- 131
- 1
- 1
-
I like this option a lot. Mounting should let you open the whole drive as a sublime project. – Mic Fok Nov 07 '14 at 21:14
I've been working on a project called GitSync. It still needs some work, but it's open source and I've been using it every day for a couple of years. I'm also working on a native OS X version I've called GitSyncApp
Right now it's OS X only but it should be easy to add support for Linux, and possibly Windows too.
It works by watching file system events and it uses to git to sync a project folder on your local machine and a server.
I tried the other solutions like osx fuse, Expand Drive, Transmit, several solutions that used rsync, etc. They all work 'OK' for small projects, but if you're working with a lot of code they did not work for me.
A lot of the file system options do caching to improve performance, which is fine, until it's not. Like if you're working with other people and someone else changes the files on the server.
I also ran into issues if I was on a flaky or slow network where I'd end up with empty files. Or file that didn't sync, then the caching got weird; hopefully you committed recently. Using git solves this problem because it checks each commit's integrity.
Two bonus features:
- You end up with a commit for every save. It's not super useful but if you ever have to go back in time you can.
- It works with any text editor.

- 36,492
- 15
- 194
- 265

- 2,025
- 2
- 19
- 26
-
I did something very similar and explain it here: [Work on a remote project with Eclipse via SSH](https://stackoverflow.com/a/60315754/4561887). The script I wrote is [sync_git_repo_from_pc1_to_pc2.sh](https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/useful_scripts/sync_git_repo_from_pc1_to_pc2.sh). Readme: [README_git-sync_repo_from_pc1_to_pc2.md](https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/useful_scripts/README_git-sync_repo_from_pc1_to_pc2.md) – Gabriel Staples Jan 18 '23 at 00:32
Depending on your exact needs, you may consider using BitTorrent Sync. Create a shared folder on your home PC and your work PC. Edit the files on your home PC (using Sublime or whatever you like), and they will sync automatically when you save. BitTorrent Sync does not rely on a central server storing the files (a la Dropbox and the like), so you should in theory be clear of any issues due to a third party storing sensitive info.

- 139
- 1
- 6
A solution that worked great for me - edit locally on Mac, and have the file automatically synchronized to a remote machine
Make sure you have passwordless login to the remote machine. If not, follow these steps http://osxdaily.com/2012/05/25/how-to-set-up-a-password-less-ssh-login/
create a file in ~/Library/LaunchAgents/filesynchronizer.plist, with the following content:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>filesynchronizer</string> <key>ProgramArguments</key> <array> <string>/usr/bin/rsync</string> <string>-avz</string> <string>/Users/USERNAME/SyncDirectory</string> <string>USERNAME@REMOTEMACHINE:~</string> </array> <key>WatchPaths</key> <array> <string>/Users/USERNAME/SyncDirectory</string> </array> </dict> </plist>
In a terminal window run
launchctl load ~/Library/LaunchAgents/filesynchronizer.plist
That's it. Any changes to any files in ~/SyncDirectory will be synchronized to ~/SyncDirectory on the remote machine. Local changes will override any remote changes.
This creates a launchd job that monitors SyncDirectory, and whenever anything changes there runs rsync to synchronize the directory to the remote machine.

- 561
- 2
- 6
This applies to Mac and Windows users (I use on Mac) . I've used several of the listed answers over the years and have found that FileZilla suits my needs well when editing files on a remote host that I have SSH access to. It's also quick to setup.
- I config a new server connection
- connect to the server
- right click on the file I'd like to edit and select
View/Edit
.
This brings up my default editor (Sublime) but it will work with any editor you have installed.
- Once I save the file, Filezilla automatically prompts me asking if I'd like to "Upload this file back to the server", I click "Yes" and then it's updated.

- 73
- 6