sshfs 的 fstab 中忽略了“exec”选项,需要在命令行上指定“mount”吗?

sshfs 的 fstab 中忽略了“exec”选项,需要在命令行上指定“mount”吗?

我在 fstab 中使用 sshfs 在 Ubuntu 18.04.04 LTS 中挂载文件系统:

sshfs#[email protected]:/remote-dir /mnt/local-mnt  fuse    rw,exec,user,allow_other,noauto,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3  0 0

它安装得很好,但如果我尝试执行路径中的任何内容,我会得到:

./some-executable: Permission denied.

该文件具有执行权限(如果我实际上通过 ssh 进入系统,则可以正常工作)。

如果我使用 fstab 但再次包含 -oexec 选项:

mount /mnt/local-mnt -oexec

然后就可以了。为什么 fstab 'exec' 被忽略?

答案1

exec选项不会被忽略 - 它会被noexec与后续user选项关联的隐式覆盖。这种行为在以下内容中提到man mount

   user   Allow an ordinary user to mount the filesystem.  The name of the
          mounting user is written to the mtab file  (or  to  the  private
          libmount  file  in /run/mount on systems without a regular mtab)
          so that this same user can unmount the filesystem  again.   This
          option  implies  the  options  noexec, nosuid, and nodev (unless
          overridden  by  subsequent  options,  as  in  the  option   line
          user,exec,dev,suid).

exec您可以通过在选项后指定选项来获得所需的行为user

也可以看看

相关内容