如何执行通过 sshfs 挂载的文件?

qui*_*inn 2 linux mount sshfs fstab file-permissions

这不起作用:

$ touch testfile
$ chmod 777 testfile
$ ls -l testfile
-rwxrwxrwx 1 quinn dialout 0 Apr 18 10:15 testfile
$ ./testfile
-bash: ./testfile: Permission denied
$ sudo ./testfile
sudo: unable to execute ./testfile: Permission denied
Run Code Online (Sandbox Code Playgroud)

我正在通过我的 fstab 中的这一行进行安装:

sshfs#127.0.0.1:/remote-dir /data/local-dir fuse port=2222,user,uid=1000,allow_other 0 0
Run Code Online (Sandbox Code Playgroud)

注意:我通过端口 2222 连接到本地主机,因为我使用的是隧道。

小智 6

您需要将exec选项添加到 fstab 行。

fstabArchWiki 页面

exec - Allow execution of binaries on the filesystem.
...
user - Allow any user to mount the filesystem.
       This automatically implies noexec, nosuid, nodev, unless overridden.
Run Code Online (Sandbox Code Playgroud)

所以你有user,但user暗示noexec,所以你需要添加exec来否定它。