Before you read this make sure that you are able to log in to the remote server you are trying to mount using ssh without a password; If not then follow the instructions on this blog.
Next you will need to install macFUSE and sshfs. You can download macFUSE and sshfs from here https://macfuse.github.io/
Once you have them installed make a directory in your home directory and mount the remote server to it from the command line
sshfs user@fqdn.co.uk:/folder ~/mountpoint -oreconnect,allow_other,volname=anyMeaningfulName
If it mounts without a password then you can move on to getting it to automount. To do this you need to create an xml file in ~/Library/LaunchAgents/ The name of this file can be anything, but convention says that it is named according to rdns convention then folder then literal “sshfs” and the final suffix is “plist”. Whatever you decide to name it the suffix must always be .plist.
so using the above it would be:
uk.co.fqdn.folder.sshfs.plist
the contents of the daemon configuration file are as follows:
<?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>NAME.sshfs</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/sshfs-authsock</string> <string>user@fqdn.co.uk:/folder</string> <string>/Users/username/mountpoint</string> <string>-oreconnect,auto_cache,volname=anyMeaningfulName</string> <string>-f</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
If the folder happens to be mounted at this point then you need to unmount it
umount ~/mountpoint
Make sure that the folder is not mounted and then issue the following 2 commands
launchctl load ~/Library/LaunchAgents/uk.co.fqdn.folder.sshfs.plist launchctl start uk.co.fqdn.folder.sshfs.plist
Now check that the folder is mounted. If it is then you are done, it should automount on reboot. If it doesn’t then unload it, edit the configuration file and try again.
launchctl unload ~/Library/LaunchAgents/uk.co.fqdn.folder.sshfs.plist
You might need to stop any stray sshfs processes. Use
ps auxwww | grep sshfs
to see if any are running.
Acknowledgement to oliora https://superuser.com/questions/134140/mount-an-sshfs-via-macfuse-at-boot
Recent Comments