Writing remote code on a Mac with SSHFS

Ever wondered how to best develop on a remote box but still finding yourself stuck with Sublime Text/Atom/Visual Studio Code on your Mac?

I’m going to show you how to do it with a tool that I personally use called SSHFS. You won’t need to download text editor plugins again.

As long as you have SSH privileges and credentials, you should be able to use this method.

Installation

Go ahead and install sshfs via Homebrew:

brew install sshfs

It might / might not prompt you to first install a program calledosxfuse. If you run into this, go ahead and run:
brew cask install osxfuse
then attempt to install sshfs again.

Mounting your remote directory

Let’s first create a local directory onto where the remote files/folders will mount to. I picked Desktop for example:

mkdir ~/Desktop/mount_folder

Now comes the fun part! a TLDR of how sshfs works is this:

sshfs [user@]hostname:[directory] mountpoint

For example, let’s say I have a repository named hologram-python sitting on my Raspberry Pi (username: pi , hostname: zheng-pi) in the /home/pi/hologram-python directory, this command will be:

sshfs pi@zheng-pi:/home/pi/hologram-python ~/Desktop/mount_folder

Hurray! You’re done! You can now make edits to files/folders that look “local”, and still see the changes in your remote machine!

Unmounting

Once you’re done, you probably want to unmount it. This is the format for doing it on a Mac:

umount mountpoint

In our example, this will be:

umount ~/Desktop/mount_folder
NOTE: If you get an error message that says the drive is busy and that you should use diskutil, it’s probably because you have a file/folder opened somewhere, and it cannot be unmounted. Close the appropriate files/folders and try again.

Additional Information

For more info, you can visit the sshfs page here: