大网数据广告活动
服务器运维问答

Prevent writing to unmounted sshfs mount point

· 52CE 我爱测

Assuming I have a folder /mnt/mountpoint that I use as a mountpoint for some sshfs -mounted directory: sshfs user@host /mnt/mountpoint Now, I want to prevent applications to write to /mnt/mountpoint while it is unmounted. Questio…

问题原文

原帖链接 · Slizzered · CC BY-SA 3.0

Assuming I have a folder /mnt/mountpoint that I use as a mountpoint for some sshfs-mounted directory:

sshfs user@host /mnt/mountpoint

Now, I want to prevent applications to write to /mnt/mountpoint while it is unmounted. Questions I found here and here have answers that imply using

sudo chattr +i /mnt/mountpoint

which works fine to prevent any write-access. Unfortunately, it also prevents me from mounting with sshfs as a normal user.

What would be the best solution for this? I would prefer a single sshfs-command or something that at least doesn't require root privileges. Should I forego the chattr approach and try something entirely different?

已采纳解答

原帖链接 · Aaron · CC BY-SA 3.0

Mount point default permissions

Create the mountpoint with

mkdir --mode=0500 -p /mnt/mountpoint

Only the creating user will be able to write to it. You could pre-populate this from rc.local. When you mount whatever filesystem lives on top of that mount point, it will pick up the permissions of that overlay that you had set when it was mounted.

On a side note, I would avoid chattr +i as that will confuse folks and cause troubleshooting fun down the road if not everyone is aware you did that.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。