How to Set up SSHFS for Mac

Photo by Goran Ivos on Unsplash

This is a guide primarily meant to help Brown University Computer Science students get started with working remotely on department machines. If you are not part of this audience, the following instructions may still be useful, but be sure to strip out the Brown-specific parts.

  1. Install Homebrew (skip if already installed).
  2. Install OSXFuse (skip if already installed). Run brew cask install osxfuse in terminal to install. You may need to restart your computer for the install to take effect since this involves a system extension.
  3. Install SSHFS (skip if already installed). Run brew install sshfs in terminal to install.
  4. In your home directory (~), create a Makefile (make a new text file and name it Makefile). Contents are detailed at the bottom of this page.
    • Make sure you put in your cs username in the file under CS_USERNAME.
    • LOCAL_DIR is a file path where you want to mount SSHFS (there should be no existing folder for file under that file path). You probably don’t have to change this.
    • Set CODE_EDITOR to the editor of your choice:
      • put atom if you want to use Atom
      • put code if you want to use VSCode (make sure to install code command to PATH; here are instructions on how to do this)
      • put subl if you want to use Sublime (if make open-in-editor doesn’t work for you later on, try looking at this)
  5. In terminal under your home directory, run make key and input the password to your ssh private key. This way, you won’t have to enter your ssh password every time you ssh.
  6. In terminal under your home directory, run make ssh. Make sure you can log in properly. (You may need to enter you Banner password). Exit ssh by running the command exit.
  7. In terminal under your home directory, run make mount. This should mount the courses folder from CIT lab machines to the directory specified in the Makefile. If you get security prompts, just allow everything.
  8. In terminal under your home directory, run make open-in-editor. This should open the mounted course folder in the code editor of your choice. (If you have problems with this, try looking at the links in step 4.)
  9. Happy coding! Be sure to read the notes below to avoid/fix issues!

Notes:

  • To safely unmount/disconnect the sshfs drive, run make unmount in your home directory in terminal.
  • If you get errors with make mount, try running make unmount before running make mount again.
  • You will need to compile, run, and submit your CS work through SSH (in case you forgot, there a handly make ssh command in the Makefile!). Some things may work on your local machine, but a lot of stuff won’t.
  • If you don’t want to input the password to you ssh key every time you SSH or mount, running make key will work; however, you will have to run this every time you restart your Mac (shutting down makes your Mac ‘forget’ the password to your key).

Makefile Contents

# General Utils

# Dependencies: osxfuse, sshfs

# SSH & SSHFS Options
LOCAL_DIR = ~/Documents/CSCI # local location where network location will mount
CS_USERNAME = <insert username here!>
CODE_EDITOR = code # use code for vscode, atom for atom, subl for sublime

key:
    ssh-add -K ~/.ssh/id_rsa

open-in-editor: $(LOCAL_DIR)
    $(CODE_EDITOR) $(LOCAL_DIR)

mount:
    mkdir -pv $(LOCAL_DIR)
    sshfs $(CS_USERNAME)@pk-ssh.cs.brown.edu:course $(LOCAL_DIR) -oauto_cache,reconnect,defer_permissions,noappledouble,negative_vncache,volname=CSCI

unmount:
    umount -f $(LOCAL_DIR)
    rmdir $(LOCAL_DIR)

ssh: key
    ssh -AXY $(CS_USERNAME)@pk-ssh.cs.brown.edu
Raymond Cao
Raymond Cao
Computer Science Student & Tech Enthusiast

Computer science student and tech geek who loves to dive down various rabbit holes.