Mount remote folder onto your local disk on the Macbook
I like working on my Mac but like to keep my development repositories on a headless terminal on the cloud (like a Digital Ocean droplet or a AWS EC2 instance).
Usually, I simply
ssh into the server and then edit code using Vim. However, there is something really cool about Sublime Text: The text editor you'll fall in love with! There are apparently plugins to remotely edit files but I want to really feel like working on my local disk.
I was able to get this working after a bit of Google research. Here is what worked for me.
On my Mac (local machine):
Install SHFS on the Mac OSX. I downloaded and installed FUSE and SSHFS from the osxfuse site
Create the mount point for loading the remote directory and set the permissions of the local directory
sudo mkdir -p /mnt/ssh sudo chown -R $USER:staff /mnt/ssh/
- Create the directory structure that you want to mount (I find this consistency useful). I wanted to load my project called happy :-)
mkdir -p /mnt/ssh/var/www/happy
- Mount the remote directory to the local file system using
sshfs jason@XXX.XXX.XXX.XXX:/var/www/happy /mnt/ssh/var/www/happy/
I found it important to use the absolute paths from the remote filesystem. Also, it should be possible to use ssh keys but I didn't try that out yet!
If everything worked fine, you should able to do see the remote directory accessible locally. Try
ls -l /mnt/ssh/var/www/happy/
That's it! You should be able to pull the folder into Sublime Text and enjoy working off the server code!
When you are done,
unmountthe directory using ...
- Note, sometimes I had to force a umount using ..
umount -f /mnt/ssh