SSHFS

SSHFS (SSH File System) is a secure shell client used to mount remote filesystems to local machines. SSHFS uses fuse to mount filesystems in userspace.

Kernel
Since SSHFS uses FUSE it will need to be enabled in the kernel.

USE flags
There are currently no available USE flags for SSHFS.

Emerge
Use the emerge command to ask Portage to install :

Usage
In order to use SSHFS a SSH daemon needs to be running on the remote machine.

To mount a remote file system locally the right privileges will be needed. When attempting to mount a remote directory without adding a user name to the command the current active user name will be used by default. For example, if the user Larry is currently the active user on the system and this command is ran:

The command will most likely fail because 's user name will be sent to the remote system. The previous command is the equivalent of running this command:

To change the user, put the name of the user before the IP address to domain name. For example, to login to the remote system using the remote system's  user name and password, use:

Unmounting
To unmount a directory with SSHFS use the fusermount command with the  option:

Automating the connection
For remote file systems that need to be mounted frequently, it is wise to automate the sign in process. Automation can be achieved by an public/private SSH key pair combined with special instructions to mount the remote filesystem on a specific event (user login, or system boot for example).

The first step is to setup the SSH key pair on the local and remote machines. Visit the Passwordless Authentication section of the SSH article for further instructions on how set up an SSH key pair. When finished return to this article.

After the key pair has been created and properly set up, determine what event will be used to start the connection automatically. It is common for a system to attempt to remotely mount a file system upon user login or system boot. Controlling the sshfs mount depends on what software the user will be implementing in their local environment. There are several ways to handle the task.

Login shells
Most shells include support for commands to be executed during user login or logout. This section will provide examples on how to automate the connection using built in shell script.

Before proceeding, it is necessary to know which shell is being used. Execute the following command as the user of interest to determine which shell is being used:

Possible output:


 * for bash
 * for sh
 * for tcsh (csh)
 * for zsh

Bash
When using a bash shell, create a and  files in the user's home directory and add the sshfs command to the file.

Mount on shell login:

Unmounting on shell logout:

Desktop environments
Most desktop environments include methods for automatically starting programs.

OpenBox
OpenBox uses the file located in each user's home directory.

External resources

 * SSHFS FAQ on Sourceforge.net
 * SSHFS tutorial at LinuxJournal.com