SSHFS(1)
๐ฆ SSHFS(1) ยท User Commands ๐ฆ
๐ธ NAME ๐ธ
SSHFS โ filesystem client based on SSH.
๐ก SYNOPSIS ๐ก
To mount a filesystem:
sshfs [user@]host:[dir] mountpoint [options]
If host is a numeric IPv6 address, it needs to be enclosed in square brackets.
To unmount it:
fusermount3 -u mountpoint # Linux
umount mountpoint # OS X, FreeBSD
๐ DESCRIPTION ๐
Okay so SSHFS lets you mount a remote filesystem using SSH โ more precisely, the SFTP subsystem. Most SSH servers support and enable this SFTP access by default, so SSHFS is super simple to use: thereโs literally nothing to do on the server-side. ๐ฆโจ
By default, file permissions are ignored by SSHFS. Any user that can access the filesystem will be able to perform any operation that the remote server permits โ based on the credentials that were used to connect to the server. If this is undesired, local permission checking can be enabled with -o default_permissions. ๐
By default, only the mounting user will be able to access the filesystem. Access for other users can be enabled by passing -o allow_other. In this case you most likely also want to use -o default_permissions. ๐ซถ
It is recommended to run SSHFS as regular user (not as root). For this to work the mountpoint must be owned by the user. If username is omitted SSHFS will use the local username. If the directory is omitted, SSHFS will mount the (remote) home directory. If you need to enter a password sshfs will ask for it (actually it just runs ssh which asks for the password if needed). ๐ญ๐
โจ OPTIONS โจ
Hereโs the option buffet, bestie. Every flag, every value, no skips. ๐
-o opt,[opt...]โ mount options, see below for details. A variety of SSH options can be given here as well, see the manual pages forsftp(1)andssh_config(5).-h,--helpโ print help and exit.-V,--versionโ print version information and exit.-d,--debugโ print debugging information.-p PORTโ equivalent to-o port=PORT.-fโ do not daemonize, stay in foreground.-sโ Single threaded operation.-Cโ equivalent to-o compression=yes.-F ssh_configfileโ specifies alternative ssh configuration file.-1โ equivalent to-o ssh_protocol=1.-o reconnectโ automatically reconnect to server if connection is interrupted. Attempts to access files that were opened before the reconnection will give errors and need to be re-opened.-o delay_connectโ Donโt immediately connect to server, wait until mountpoint is first accessed.-o sshfs_syncโ synchronous writes. This will slow things down, but may be useful in some situations.-o no_readaheadโ Only read exactly the data that was requested, instead of speculatively reading more to anticipate the next read request.-o sync_readdirโ synchronous readdir. This will slow things down, but may be useful in some situations.-o workaround=LISTโ Enable the specified workaround. See the Caveats section below for some additional information. Possible values are:renameโ Emulate overwriting an existing file by deleting and renaming.renamexdevโ Make rename fail withEXDEVinstead of the defaultEPERMto allow moving files across remote filesystems.truncateโ Work around servers that donโt support truncate by copying the whole file, truncating it locally, and sending it back.fstatโ Work around broken servers that donโt supportfstat()by usingstatinstead.buflimitโ Work around OpenSSH โbuffer fillupโ bug.createmodeโ Work around broken servers that produce an error when passing a non-zero mode to create, by always passing a mode of0.
-o idmap=TYPEโ How to map remote UID/GIDs to local values. Possible values are:noneโ no translation of the ID space (default).userโ map the UID/GID of the remote user to UID/GID of the mounting user.fileโ translate UIDs/GIDs based upon the contents of--uidfileand--gidfile.
-o uidfile=FILEโ file containingusername:uidmappings for-o idmap=file.-o gidfile=FILEโ file containinggroupname:gidmappings for-o idmap=file.-o nomap=TYPEโ withidmap=file, how to handle missing mappings:ignoreโ donโt do any re-mapping.errorโ return an error (default).
-o ssh_command=CMDโ executeCMDinstead of'ssh'.-o ssh_protocol=Nโ ssh protocol to use (default:2).-o sftp_server=SERVโ path to sftp server or subsystem (default:sftp).-o directport=PORTโ directly connect toPORTbypassing ssh.-o vsock=CID:PORTโ directly connect using a vsock toCID:PORTbypassing ssh.-o passiveโ communicate over stdin and stdout bypassing network. Useful for mounting local filesystem on the remote side. An example usingdpipecommand would be:
dpipe /usr/lib/openssh/sftp-server = ssh RemoteHostname sshfs :/directory/to/be/shared ~/mnt/src -o passive
-o disable_hardlinkโ With this option set, attempts to calllink(2)will fail with error codeENOSYS.-o transform_symlinksโ transform absolute symlinks on remote side to relative symlinks. This means that if e.g. on the server side/foo/bar/comis a symlink to/foo/blub, SSHFS will transform the link target to../blubon the client side.-o contain_symlinksโ reject symlink targets that are absolute or contain..components. When a blocked symlink is encountered,readlinkreturnsEPERM. This is enabled by default to prevent a malicious server from inducing local file reads or writes through crafted symlink targets. Note that this is stricter thantransform_symlinks: the two options should not normally be combined, since transformed results often contain..and would be rejected by containment.-o no_contain_symlinksโ disable symlink containment and allow all symlink targets through unchanged, including absolute paths and paths containing.... Only use this with fully trusted servers.-o follow_symlinksโ follow symlinks on the server, i.e. present them as regular files on the client. If a symlink is dangling (i.e. the target does not exist) the behavior depends on the remote server โ the entry may appear as a symlink on the client, or it may appear as a regular file that cannot be accessed.-o no_check_rootโ donโt check for existence of'dir'on server.-o password_stdinโ read password from stdin (only forpam_mount!).-o dir_cache=BOOLโ Enables (yes) or disables (no) the SSHFS directory cache. The directory cache holds the names of directory entries. Enabling it allowsreaddir(3)system calls to be processed without network access.-o dcache_max_size=Nโ sets the maximum size of the directory cache.-o dcache_timeout=Nโ sets timeout for directory cache in seconds.-o dcache_{stat,link,dir}_timeout=Nโ sets separate timeout for{attributes, symlinks, names}in the directory cache.-o dcache_clean_interval=Nโ sets the interval for automatic cleaning of the directory cache.-o dcache_min_clean_interval=Nโ sets the interval for forced cleaning of the directory cache when full.-o direct_ioโ This option disables the use of page cache (file content cache) in the kernel for this filesystem. This has several affects:- Each
read()orwrite()system call will initiate one or more read or write operations, data will not be cached in the kernel. - The return value of the
read()andwrite()system calls will correspond to the return values of the read and write operations. This is useful for example if the file size is not known in advance (before reading it). e.g./procfilesystem.
- Each
-o max_conns=Nโ sets the maximum number of simultaneous SSH connections to use. Each connection is established with a separate SSH process. The primary purpose of this feature is to improve the responsiveness of the file system during large file transfers. When using more than one connection, thepassword_stdinandpassiveoptions can not be used, and thebuflimitworkaround is not supported.
In addition, SSHFS accepts several options common to all FUSE file systems. These are described in the mount.fuse manpage (look for "general", "libfuse specific", and "high-level API" options).
๐ CAVEATS / WORKAROUNDS ๐
๐ธ Hardlinks ๐ธ
ok so if the SSH server supports the hardlinks extension, SSHFS will let you create hardlinks. slay. but heads up: hardlinks will always appear as individual files when seen through an SSHFS mount, i.e. they will appear to have different inodes and an st_nlink value of 1. so likeโฆ they exist, but the vibe is โseparate filesโ from the mountโs perspective ๐ญ.
๐ Rename ๐
some SSH servers do not support atomically overwriting the destination when renaming a file. in that case youโll get an error when you try to rename a file and the destination already exists. the workaround is to first remove the destination file, and then do the rename. SSHFS can do this automatically if you call it with -o workaround=rename. but bestie, plot twist: it is still possible that someone (or something) recreates the destination file after SSHFS has removed it, but before SSHFS had the time to rename the old file. in this case, the rename will still fail. no cap.
๐ฆ Permission denied when moving files across remote filesystems ๐ฆ
most SFTP servers return only a generic โfailureโ when failing to rename across filesystem boundaries (EXDEV). sshfs normally converts this generic failure to a permission denied error (EPERM). if the option -o workaround=renamexdev is given, generic failures will be considered EXDEV errors which will make programs like mv(1) attempt to actually move the file after the failed rename. itโs giving โworkaround eraโ โจ.
๐ SSHFS hangs for no apparent reason ๐
in some cases, attempts to access the SSHFS mountpoint may freeze if no filesystem activity has occurred for some time. this is typically caused by the SSH connection being dropped because of inactivity without SSHFS being informed about that. as a workaround, you can try to mount with -o ServerAliveInterval=15. this will force the SSH connection to stay alive even if you have no activity. lowkey iconic prevention ๐
.
๐ญ SSHFS hangs after the connection was interrupted ๐ญ
by default, network operations in SSHFS run without timeouts, mirroring the default behavior of SSH itself. as a consequence, if the connection to the remote host is interrupted (e.g. because a network cable was removed), operations on files or directories under the mountpoint will block until the connection is either restored or closed altogether (e.g. manually). applications that try to access such files or directories will generally appear to โfreezeโ when this happens. itโs giving stuck-in-the-group-chat-with-no-service ๐.
if it is acceptable to discard data being read or written, a quick workaround is to kill the responsible sshfs process, which will make any blocking operations on the mounted filesystem error out and thereby โunfreezeโ the relevant applications. note that force unmounting with fusermount -zu, on the other hand, does not help in this case and will leave read/write operations in the blocking state. so yeah, donโt do that one and expect a glow-up ๐.
for a more automatic solution, one can use the -o ServerAliveInterval=15 option mentioned above, which will drop the connection after not receiving a response for 3 * 15 = 45 seconds from the remote host. by also supplying -o reconnect, one can ensure that the connection is re-established as soon as possible afterwards. as before, this will naturally lead to loss of data that was in the process of being read or written at the time when the connection was interrupted. fr fr, data loss is the price tag sometimes ๐ญ.
๐ MOUNTING FROM /ETC/FSTAB ๐
to mount an SSHFS filesystem from /etc/fstab, simply use sshfs as the file system type. (for backwards compatibility, you may also use fuse.sshfs). cute and classic ๐.
๐ SEE ALSO ๐
the mount.fuse(8) manpage.
๐ซถ GETTING HELP ๐ซถ
if you need help, please ask on the <fuse-sshfs@lists.sourceforge.net> mailing list (subscribe at <https://lists.sourceforge.net/lists/listinfo/fuse-sshfs>). bestie support network ๐.
please report any bugs on the GitHub issue tracker at <https://github.com/libfuse/libfuse/issues>. do it for the plot โจ.
๐ AUTHORS ๐
SSHFS was maintained by Nikolaus Rath <Nikolaus@rath.org>, and was created by Miklos Szeredi <miklos@szeredi.hu>.
see <https://github.com/libfuse/sshfs> for new maintainer information.
this man page was originally written by Bartosz Fenski <fenio@debian.org> for the Debian GNU/Linux distribution (but it may be used by others). historical icon behavior ๐
.
๐ and thatโs the whole page, bestie โ the footerโs source/version tag is SSHFS(1) and thereโs no date listed, so weโre wrapping it up right here โจ๐
๐ฆ where this page comes from
- alpine 3.22: sshfs-doc 3.7.6-r0 ยท GPL-2.0-or-later
- alpine 3.23: sshfs-doc 3.7.6-r0 ยท GPL-2.0-or-later
- alpine 3.24: sshfs-doc 3.7.6-r0 ยท GPL-2.0-or-later
- opensuse-leap 16.0: sshfs 3.7.6-bp160.1.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: sshfs 3.7.6-bp160.1.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: sshfs 3.7.6-bp160.1.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: sshfs 3.7.6-bp160.1.1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms