first of all, you need to install the sshfs package (apt, dnf etc)
to mount a remote server manually, the sytax is :
first of all, you need to install the sshfs package (apt, dnf etc)
to mount a remote server manually, the sytax is :
mkdir -p /local_dir/remote_server
sshfs username@server.example.com:/ /local_dir/mount_point
to mount in /etc/fstab :
username@server.example.com:/ /local_dir/mount_point sshfs noauto,x-systemd.automount,_netdev,reconnect,identityfile=/home/localuser/.ssh/private_key.rsa,allow_other,default_permissions 0 0
breaking down the options:
option | details |
---|---|
noauto | do not mount when mount -a is given (e.g., at boot time) |
x-systemd.automount | let systemd mount it on access. |
_netdev | Using this option overrides this detection and specifies that the mount requires network. |
reconnect | reconnect to server |
identityfile | Selects a file from which the identity (private key) for public key authentication is read. |
allow_other | This option overrides the security measure restricting file access to the filesystem owner, so that all users (including root) can access the files. |
default_permissions |
This option instructs the kernel to perform its own permission check instead of deferring all permission checking to the filesystem. The check by the kernel is done in addition to any permission checks by the filesystem, and both have to succeed for an operation to be allowed. The kernel performs a standard UNIX permission check (based on mode bits and ownership of the directory entry, and uid/gid of the client). This mount option is activated implicitly if the filesystem enables ACL support during the initial feature negotiation when opening the device fd. In this case, the kernel performs both ACL and standard unix permission checking. Filesystems that do not implement any permission checking should generally add this option internally. |
some extra notes :
if you use the option allow_other, you will have to add in in /etc/fuse.conf as well.
if you add default_permissions, you may not be able to do a move operation without being root
sources :
https://linux.die.net/man/1/sshfs
https://www.man7.org/linux/man-pages/man5/fstab.5.html
https://www.freedesktop.org/software/systemd/man/systemd.automount.html#
https://www.freedesktop.org/software/systemd/man/systemd.mount.html#
https://wiki.archlinux.org/title/Fstab#Automount_with_systemd