Mount directory from a remote server with sshfs

Mount directory from a remote server with sshfs

sshfs is an external tool and can be installed with sudo apt install -yq sshfs.


Your server is at example.com. To mount a directory from the server, execute

sshfs example.com:<remote dir> <local dir>.

Both <remove dir> and <local dir> must exist. And <local dir> must be empty.

Disk space is occupied in the remote server, not in local.

To unmount, use fusermount -u <local dir>.


To auto-reconnect and periodically ping server, in order to prevent disconnection. Add this flag -o reconnect,ServerAliveInterval=30,ServerAliveCountMax=100 after sshfs.


If you use a mounted directory to mount to a docker volume. There will be an error similar to the following

Error response from daemon: Cannot restart container csgo-dedicated2: OCI runtime create failed: container_linux.go:346: starting container process caused "chdir to cwd ("/home/steam/csgo-dedicated") set in config.json failed: permission denied": unknown

In that case, you should add -o allow_other to the sshfs command. Please remember to unmount the volume first, before re-mount with this option.


If it happens another permission error, you should go to the remote PC (the owner of the storage). Then change the owner/group IDs of the directory to be the user/group of the user used in the sshfs command.

sudo chown <username or id> <dir path>
sudo chgrp <group name or id> <dir path>
Buy Me A Coffee