SSHFS allows users to securely access remote filesystems over the SSH protocol. This guide will help you get started with SSHFS on Linux or MacOS X. SSHFS eliminates the need to use specialized software (such as SFTP/FTP clients) to transfer files to and from a remote server. This document assumes the server hosting the filesystem you wish to access has an SSH daemon running on it, and that you have an account on the server with sufficient privileges to access the desired filesystem locations.
This example uses Debian 5 (Lenny) as the client operating system. We'll be accessing a remote server running Ubuntu 9.04. Issue the following commands to ensure that your system's package database is up to date and the latest versions of your packages have been installed:
apt-get update apt-get upgrade
Issue the following command to install sshfs:
apt-get install sshfs
The above sequence of commands will work on Ubuntu clients as well. If you're running CentOS or Fedora on the client, issue the following commands to install the client and ensure that your system is up to date:
yum update yum install sshfs
After the required packages are installed, you may use the sshfs command in your terminal to mount a remote filesystem. If you wish to use a normal user account to mount filesystems using SSHFS, you'll need to add your user to the fuse group first. Execute the following command as root, substituting your user account name for "someuser":
usermod -a -G fuse someuser
Log out and log back into the client system before proceeding using a normal user account. If we wanted to mount the home directory of a user named "alex" on a remote server named "archimedes.example.com", we might issue the following commands:
mkdir alex-archimedes sshfs email@example.com:/home/alex alex-archimedes
To umount the filesystem, issue the umount command:
If you'd like to make a filesystem mount persistent between reboots, you may modify your /etc/fstab file to include an entry for it. Before doing so, you'll need to make sure you can log into the remote server without entering a password; you'll need to configure SSH keys to accomplish this. This will allow you to mount the remote filesystem without needing to enter a password.
You might issue the following commands to generate an SSH key and copy it to the remote server's authorized_keys2 file. Please note that this file may be named authorized_keys instead; consult your remote server's configuration file (usually /etc/ssh/sshd_config) if you're unsure which filename is valid. Note that these commands are for the fictional "example.com" server. You'll need to substitute values appropriate for your server in commands that include a hostname or user account name.
If your remote server user account doesn't already have key in ~/.ssh, issue this command on the remote server, accepting the defaults:
ssh-keygen -t rsa
If your local (client) user account doesn't already have keys in ~/.ssh, issue the same command on the client system, accepting the defaults:
ssh-keygen -t rsa
Issue these commands on the client system to copy your public SSH key to the remote server:
scp ~/.ssh/id_rsa.pub firstname.lastname@example.org:/home/alex/.ssh/uploaded_key.pub ssh email@example.com "echo \`cat ~/.ssh/uploaded_key.pub\` >> ~/.ssh/authorized_keys2"
At this point, you should be able to log into the remote server as "alex" without entering a password. Next, you may modify your local client's /etc/fstab file to include a mount directive for the remote user directory.
firstname.lastname@example.org:/home/alex /root/alex-archimedes fuse defaults 0 0
This entry would mount the home directory for "alex" on the server "archimedes.example.com" locally at /root/alex-archimedes each time the system is booted. You may treat this entry like any other in /etc/fstab; please consult the man page for fstab for an in-depth explanation of available options.
With MacFUSE and Macfusion, you can mount remote filesystems over SSH in Mac OS X. You may use Finder or the terminal to access files in this manner.
Visit the MacFUSE homepage to download a current copy of the MacFUSE installer for MacOS X 10.5 or greater. Open the disk image in Finder and double-click "MacFUSE.pkg" to start the installation process:
You'll be presented with information on MacFUSE. Click "Continue" to proceed:
Review the software license agreement and click "Continue" to proceed:
Click "Install" to confirm installation:
As stated in the installer, please restart your system before proceeding further. This is to ensure MacFUSE is running properly before you proceed with later steps.
Once MacFUSE is installed, visit the Macfusion homepage and extract the program to your desktop. Double-click the Macfusion icon to start the program. Select the option to start the agent automatically if desired, and click "Start" to continue:
You will be presented with an empty connection list. Click the "+" icon in the bottom left of the window and select "SSHFS" to continue:
Fill in your server and remote user account details on the "SSH" tab. Optionally, you can specify a remote filesystem path.
On the "Macfusion" tab, you may select a mount point for this filesystem. Do not specify a directory that already exists; a link will be created at the location you specify here.
Allow Macfusion to access your keychain:
Once all connection information is entered, click "Mount" in the connection list. Your remote server will mounted at the location you specified.
Use Finder to navigate to the location your remote filesystem is mounted at locally.
Double-click on the icon to display the contents of your remote filesystem.
Congratulations! You've mounted a remote filesystem via SSH on MacOS X.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This guide is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.
Last edited by Phil Paradis on Tuesday, May 17th, 2011 (r1920).