Startpagina > Netwerkbeheer > sshfs

sshfs: Mount remote file systems via SSH

sshfs is a client that allows you to mount a remote server's directory to your local file system using the SSH File Transfer Protocol. This allows you to browse and edit remote files as if they were on a local disk. It works based on FUSE (Filesystem in Userspace).

Overview

sshfs mounts the file system of a remote server to a local directory via an SSH connection, allowing you to access and manage remote files as if they were local. This is particularly useful when frequently editing remote files or dealing with large amounts of data.

Key Features

  • Based on FUSE (Filesystem in Userspace)
  • Data transfer via secure SSH connection
  • Direct access and editing of remote files as if local
  • Provides various mount options (permissions, caching, compression, etc.)

Installation

sshfs is not included by default in most Linux distributions, so you need to install it using your package manager.

Debian/Ubuntu

sudo apt update && sudo apt install sshfs

Install using the apt package manager.

Fedora/CentOS/RHEL

sudo dnf install sshfs

Install using the dnf (or yum) package manager.

Main Options

sshfs offers various options to finely control mount behavior. Most options are used after the `-o` flag, separated by commas.

Connection and Permissions

Performance and Behavior

Gegenereerde opdracht:

Probeer de opdrachtcombinaties.

Uitleg:

`sshfs` Voer het commando uit.

Combineer deze opties en voer de opdracht virtueel uit met de AI.

Usage Examples

Various ways to mount and use remote directories locally with sshfs.

Basic Mount

mkdir -p /local/mount/point
sshfs user@remote_host:/remote/path /local/mount/point

Mounts `/remote/path` on the remote server to `/local/mount/point` locally. The mount point must be created beforehand.

Using a Specific SSH Port

sshfs -o port=2222 user@remote_host:/remote/path /local/mount/point

Attempts to connect via SSH on a port other than the default 22 (e.g., 2222).

Allowing Access for Other Users

sshfs -o allow_other user@remote_host:/remote/path /local/mount/point

Allows other users besides the mounting user to access the mounted file system.

Using SSH Key File

sshfs -o IdentityFile=~/.ssh/id_rsa user@remote_host:/remote/path /local/mount/point

Authenticates using an SSH key file instead of a password.

Unmounting

fusermount -u /local/mount/point

Unmounts the mounted file system. `fusermount` is used to safely unmount FUSE file systems.

Tips & Precautions

Useful tips and points to be aware of when using sshfs.

Importance of Unmounting

After completing your work, always unmount using the command `fusermount -u `. Failure to do so can lead to system instability or file system errors.

Performance Optimization

In environments with high network latency, you can improve performance by using the `cache=yes` option. Conversely, `compression=yes` can increase CPU usage, so consider the balance between network bandwidth and CPU resources when using it.

Permission Issues

The `allow_other` option permits other users to access the mounted file system. Use it with caution regarding security. If necessary, you can use the `uid` and `gid` options to mount with the permissions of a specific user/group.

Automatic Mounting (fstab)

To automatically mount sshfs at system boot, you can edit the `/etc/fstab` file. However, this method requires additional configuration such as SSH key authentication and may cause issues depending on network connectivity, so configure it carefully.


Hétzelfde categoriecommando