我想在我的Debian机器上通过sshfs
挂载一个远程目录,比如/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获得正确的权限?
答案 0 :(得分:26)
在allow_other
中使用选项/etc/fstab
允许其他用户访问已安装的文件系统。当您启动系统并挂载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。
答案 1 :(得分:2)
另外补充以前的答案:
您应该更喜欢[用户] @ [主机]语法而不是sshfs#[user] @ [host] one。
确保允许非root用户在/etc/fuse.conf中指定allow_other挂载选项
确保在root时手动使用每个sshfs mount至少一次,以便将主机的签名添加到.ssh / known_hosts文件中。
$ sudo sshfs [user] @ [host]:[remote_path] [local_path] -o allow_other,IdentityFile = [path_to_id_rsa]
答案 2 :(得分:0)
此外,作为已接受的答案的补充:在目标计算机上,目标计算机上的用户必须拥有sudo chsh username
-> /bin/bash
上的外壳程序权限。
我有一个用户使用/ bin / false,这会引起问题。