gpt4 book ai didi

linux - 通过 fstab 作为普通用户使用 Sshfs

转载 作者:IT王子 更新时间:2023-10-29 00:26:17 62 4
gpt4 key购买 nike

我想通过 sshfs 在我的 Debian 机器上挂载一个远程目录,例如 /work。所以我将我的用户添加到 fuse 组并运行:

sshfs user@remote.machine.net:/remote/dir /work

一切正常。然而,在引导时挂载该目录会非常好。所以我尝试了下面给出的 /etc/fstab 条目:

sshfs#user@remote.machine.net:/remote/dir /work     fuse      user,_netdev,reconnect,uid=1000,gid=1000,idmap=user  0   0

sshfs 要求输入密码并几乎正确安装。几乎是因为我的常规 user 无法访问挂载的目录,当我运行 ls -la/ 时,我得到:

d?????????   ? ?        ?               ?            ? work

如何通过 fstab 获得正确的权限?

最佳答案

/etc/fstab 中使用选项 allow_other 允许其他用户而不是进行实际挂载的用户访问已挂载的文件系统。当您启动系统并安装 sshfs 时,它是由用户 root 而不是普通用户完成的。当您添加 allow_other 时,root 以外的其他用户可以访问挂载点。挂载点下的文件权限仍然和以前一样,所以如果你有一个掩码为 0700 的目录,除了 root 和所有者之外,其他任何人都无法访问它。

所以,而不是

sshfs#user@remote.machine.net:/remote/dir /work     fuse      user,_netdev,reconnect,uid=1000,gid=1000,idmap=user  0   0

使用

sshfs#user@remote.machine.net:/remote/dir /work     fuse      user,_netdev,reconnect,uid=1000,gid=1000,idmap=user,allow_other  0   0

这至少对我有用。我没有通过启动系统来测试它,而是以 root 身份发出 mount 命令,然后尝试以普通用户身份访问已挂载的 sshfs。

关于linux - 通过 fstab 作为普通用户使用 Sshfs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19971811/

62 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com