sshfs
Mount remote filesystems over SSH
TLDR
Mount remote directory
Unmount remote directory
Mount remote directory from server with specific port
Use compression
Follow symbolic links
SYNOPSIS
sshfs [user@]host:[directory] mountpoint [-o options]
PARAMETERS
user@host:directory
Specifies the remote host and the directory to be mounted. The user@ part is optional if the username is the same as local or defined in SSH config.
mountpoint
The local directory where the remote filesystem will be mounted.
-o reconnect
Automatically tries to reconnect if the SSH connection is lost.
-o identity_file=path
Specifies a path to an SSH identity (private key) file for authentication.
-o port=number
Specifies the SSH port number on the remote host.
-o no_check_host_ip
Disables checking the host IP address against known_hosts. Use with caution.
-o idmap=mode
Specifies how to map user and group IDs between local and remote systems (e.g., user, file, none).
-o uid=id
Overrides the user ID of all files on the mounted filesystem.
-o gid=id
Overrides the group ID of all files on the mounted filesystem.
-o umask=mode
Sets the umask for newly created files and directories on the mounted filesystem.
-o allow_other
Allows other users on the local system to access the mounted filesystem.
-o defer_permissions
Defers permission checking to the server, allowing SSH to handle permissions.
-o transform_symlinks
Attempts to transform remote absolute symlinks into relative ones to make them work locally.
-o ssh_command=cmd
Specifies an alternative ssh command to execute for the connection.
-o direct_io
Uses direct I/O for file operations, bypassing the kernel page cache for mounted files.
-o ro
Mounts the filesystem in read-only mode.
-o nonempty
Allows mounting on a directory that is not empty.
-o default_permissions
Enables default kernel-level permission checking on the mounted filesystem.
-o compression=yes/no
Enables or disables SSH compression for data transfer.
DESCRIPTION
sshfs (SSH Filesystem) is a FUSE-based client that allows you to mount a remote directory on your local machine using the Secure Shell (SSH) protocol. It provides a convenient and secure way to access and interact with files on a remote server as if they were stored locally.
sshfs leverages SSH's authentication and encryption capabilities, ensuring that all data transfer is secure. It's particularly useful for tasks like editing remote files with local tools, navigating remote directories with graphical file managers, or accessing large datasets without needing to transfer them entirely. Because it's built on FUSE (Filesystem in Userspace), it runs as a user-space program, simplifying its deployment and usage without requiring kernel modifications.
CAVEATS
sshfs performance can be significantly affected by network latency and bandwidth due to its reliance on the SSH protocol and FUSE overhead. Certain file operations, especially those involving many small files or random access, might be slow. File locking and other advanced POSIX features may not behave as expected or might be unreliable, as they depend on the remote server's file system and SFTP server capabilities.
It's generally not recommended for high-performance computing or for applications that require very low-latency, high-throughput access to remote data.
UNMOUNTING
To unmount an sshfs filesystem, use the umount command followed by the mountpoint. For example: umount /mnt/remote_dir
If the mount is busy, you might need to use umount -l (lazy unmount) or, as a last resort, umount -f (force unmount, use with caution as it can lead to data inconsistencies).
SECURITY CONSIDERATIONS
While sshfs provides secure data transfer through SSH encryption, ensure that the SSH keys or passwords used are strong and protected. Be cautious when using options like allow_other or no_check_host_ip, as they can reduce security if not properly understood and configured. Always follow best practices for SSH security, including using key-based authentication instead of passwords where possible.
HISTORY
sshfs was primarily developed by Miklos Szeredi, the creator of FUSE (Filesystem in Userspace), in the early 2000s. It quickly gained popularity as a simple yet powerful tool for remote file access, leveraging the ubiquitous SSH protocol to provide secure and convenient file system mounting without requiring complex server-side configurations beyond a standard SSH daemon. Its integration with FUSE made it easily deployable in user-space, avoiding the complexities of kernel modules and making secure remote file access broadly accessible.