我知道 sshfs 用于将远程目录挂载到本地,但我需要将本地目录挂载到远程 fs。
我想挂载一个本地文件夹,例如:
/home/username/project_directory
Run Code Online (Sandbox Code Playgroud)
到我可以通过 ssh 访问的远程机器上,例如:
/var/www/project_directory
Run Code Online (Sandbox Code Playgroud)
目标是在本地进行的编辑反映在远程文件系统上。
这不起作用:
$ 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 连接到本地主机,因为我使用的是隧道。