Skip to content. | Skip to navigation

Personal tools
Log in
You are here: Home How To OS X Admin De-Luxe SSHFS for OS X

De-Luxe SSHFS for OS X

A deluxe setup for sshfs mounting on OS X upon login.

Here's what to do:

  1. Install Fink if you don't have it.
  2. Install sshfs using Fink from /Applications/Utilities/Terminal:
    fink install sshfs
  3. Make this script in /Applications/Utilities/ApplesScript Editor:
    with timeout of 300 seconds
    	tell application "Finder"
    		do shell script "/sw/bin/sshfs /Users/apple_account/sshfs/remote_mount"
    	end tell
    end timeout
  4. Change the following in the script above :
    • remote_account to the login for your remote account to which you will ssh
    • to the name of the remote server to which you will ssh
    • apple_account to the name of the login for your account on OS X
    • remote_mount to a name you wish to call the remote sshfs mount
  5. In AppleScript Editor save the script as a script in case you need to edit it later:
    • File -> Save As...
      • Save As: mount_remote.scpt (or something)
      • File Format: Script
  6. In AppleScript Editor save the script also as an Application in the Applications directory of your home folder on OS X. In Finder, this folder will be found by clicking on your home folder (house icon), NOT by clicking on the Applications icon in the PLACES section of the Finder sidebar.
    • File -> Save As...
      • File Format: Application
  7. From the script you made above, note the path to the mount and make the directory in Terminal:
    mkdir -p /Users/apple_account/sshfs/remote_mount
  8. As sudoer (you need to be an administrator for your OS X box), you need to make an ssh-askpass in the /usr/libexec directory.
    • Filled with the following content, make a file called ssh-askpass on your Desktop using a TRUE (not TextEdit, etc.) text editor like vim or TextWrangler:

      #! /bin/sh
      # An SSH_ASKPASS command for MacOS X
      # Author: Joseph Mocker, Sun Microsystems
      # To use this script:
      #     setenv SSH_ASKPASS "macos-askpass"
      #     setenv DISPLAY ":0"
      DIALOG="display dialog \"$@\" default answer \"\" with title \"$TITLE\""
      DIALOG="$DIALOG with icon caution with hidden answer"
      result=`osascript -e 'tell application "Finder"' -e "activate"  -e "$DIALOG" -e 'end tell'`
      if [ "$result" = "" ]; then
          exit 1
          echo "$result" | sed -e 's/^text returned://' -e 's/, button returned:.*$//'
          exit 0
    • Copy ssh-askpass to /usr/libexec/:
      sudo cp ~/Desktop/ssh-askpass /usr/libexec
    • Change the permissions to allow it to be run as an executable:
      sudo chmod a+rx /usr/libexec/ssh-askpass
  9. Get rid of the annoying bouncing Dock item for your AppleScript application.
    • Using Finder, navigate to the Applications directory in your home folder on your OS X box.
    • Right-click on the application you created above and click Show Package Contents in the contextual menu.
    • In the resulting window, called "Contents", double-click the Info.plist file to open it with Property List Editor.
    • Right-click on the top row of the property list (called "Information Property List") and select Add Row.
    • The Key for the new row is NSUIElement and the value is 1.
    • Save and close the Info.plist file.
  10. Make the sshfs mount when you login.
    • In /Applications/System Preferences (also found in the Apple Menu), hit Show All.
    • Click on Accounts.
    • Click on Login Items.
    • Hit the + and select the script application you made above.
    • Although it is already a hidden item, it doesn't hurt to check the Hide checkbutton.
  11. Logout and login to give it a try. When you login, you will be prompted for your password for the remote computer. After it mounts, if it doesn't show up under the DEVICES section of the Finder sidebar, you can navigate finder to the mount point you specified above and drag the mount to DEVICES.