Linux command
sshfs 命令
安全
需要网络或远程资源。
常用示例
Mount a remote directory
sshfs [user]@[host]:[remote/path] [local/mountpoint]
Mount using a specific SSH port
sshfs [user]@[host]:[remote/path] [local/mountpoint] -p [2222]
Mount with SSH key authentication
sshfs -o IdentityFile=[~/.ssh/key] [user]@[host]:[path] [mountpoint]
Mount allowing other users
sshfs -o allow_other [user]@[host]:[path] [mountpoint]
Unmount the remote filesystem
fusermount -u [mountpoint]
Mount with reconnection
sshfs -o reconnect [user]@[host]:[path] [mountpoint]
说明
sshfs is a filesystem client based on FUSE (Filesystem in Userspace) that allows you to mount remote directories over an SSH connection. Once mounted, the remote filesystem can be accessed like any local directory, using standard file operations. The tool uses the SSH protocol for secure data transfer, leveraging existing SSH configurations including authentication keys, proxy settings, and host configurations from ~/.ssh/config. This makes it an excellent alternative to NFS or Samba for accessing remote files when SSH access is already available. SSHFS is particularly useful for development workflows, allowing local editors and tools to work on remote files transparently. It handles disconnections gracefully and can automatically reconnect when network connectivity is restored.
参数
- -o _options_
- Mount options (comma-separated)
- -p _port_
- SSH port to connect to
- -C
- Enable compression
- -F _ssh_config_
- SSH config file to use
- -1
- Use SSH protocol version 1
- -o IdentityFile=_file_
- Path to SSH private key
- -o allow_other
- Allow other users to access the mount
- -o allow_root
- Allow root to access the mount
- -o reconnect
- Reconnect to server on connection drop
- -o ServerAliveInterval=_seconds_
- Send keepalive messages to prevent timeout
- -o StrictHostKeyChecking=no
- Don't verify host key (use with caution)
- -o cache=yes
- Enable caching (improves performance)
- -o kernel_cache
- Enable kernel caching
- -o idmap=user
- Map remote user's UID/GID to the local mounting user
- -o transform_symlinks
- Rewrite absolute symlinks as relative to the mountpoint
- -o follow_symlinks
- Follow symlinks on the server side
- -o max_conns=_N_
- Maximum number of concurrent SSH connections
- -f
- Run in foreground (for debugging)
- -d
- Debug mode
FAQ
What is the sshfs command used for?
sshfs is a filesystem client based on FUSE (Filesystem in Userspace) that allows you to mount remote directories over an SSH connection. Once mounted, the remote filesystem can be accessed like any local directory, using standard file operations. The tool uses the SSH protocol for secure data transfer, leveraging existing SSH configurations including authentication keys, proxy settings, and host configurations from ~/.ssh/config. This makes it an excellent alternative to NFS or Samba for accessing remote files when SSH access is already available. SSHFS is particularly useful for development workflows, allowing local editors and tools to work on remote files transparently. It handles disconnections gracefully and can automatically reconnect when network connectivity is restored.
How do I run a basic sshfs example?
Run `sshfs [user]@[host]:[remote/path] [local/mountpoint]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o _options_ do in sshfs?
Mount options (comma-separated)