简体   繁体   English

使用Webmin挂载NFS时,权限被拒绝(Mac OSX + Ubuntu安装程序)

[英]Permission Denied with mounting NFS with Webmin (Mac OSX + Ubuntu Setup)

The Goal 目标

I have the following setup - 我有以下设置-

  • Home Server running Ubuntu 13.10 运行Ubuntu 13.10的家庭服务器
  • Laptop running Mac OSX 10.9 (Mavericks) 运行Mac OSX 10.9的笔记本电脑(小牛)

I'm trying to export the Home Server directory ~/Documents as an NFS mount that can be accessed from my mac laptop 我正在尝试将Home Server目录〜/ Documents导出为可从Mac笔记本电脑访问的NFS挂载

Ubuntu Setup Ubuntu安装程序

I used Webmin on Ubuntu to create an NFS Export. 我在Ubuntu上使用Webmin创建了NFS导出。 In the interest of just testing access for the moment I allowed any hostname to connect with read/write access. 为了暂时只测试访问权限,我允许任何主机名以读/写访问权限连接。

Webmin created the following configuration under /etc/exports Webmin在/etc/exports下创建了以下配置

/home/jeeves/Documents        (insecure,no_subtree_check,no_root_squash,rw,nohide)

Mac OX 10.9 Laptop Setup Mac OX 10.9笔记本电脑设置

I mounted the remote directory to a local directory, /private/nfs 我将远程目录安装到本地目录/private/nfs

sudo mount -t nfs 192.168.1.219:/home/jeeves/Documents /private/nfs 

All worked fine, and I can see "Dcouments" mounted under /private in Finder. 一切正常,我可以在Finder中的/private下看到“ Dcouments”。

However, I can't get into that directory 但是,我无法进入该目录

jeeves:~ $ cd /private/nfs/
-bash: cd: /private/nfs/: Permission denied

I had webmin set permissions as read/write ( rw ) and it's not filtering on any IP's or hostnames, so what else is required to access that directory? 我已经将webmin的权限设置为读/写( rw ),并且没有对任何IP或主机名进行过滤,因此访问该目录还需要什么?

Thanks in advance for all your help! 预先感谢您的所有帮助!

Edit : 编辑

Here's my Webmin setup. 这是我的Webmin设置。

在此处输入图片说明

Webmin wont let me select an NFS version of 4, presumably because I only have NFS v3 installed, as per nfsstat Webmin不会让我选择4的NFS版本,大概是因为根据nfsstat ,我仅安装了NFS v3

jeeves@HAL:~$ nfsstat
...
Server nfs v3:
null         getattr      setattr      lookup       access       readlink     
25        5% 28        6% 0         0% 126      29% 211      48% 0         0% 
...

You're likely running into an issue with numeric user id's: the numeric user id on your ubuntu system does not match the numeric user id on your Mac. 您可能会遇到数字用户ID的问题:Ubuntu系统上的数字用户ID与Mac上的数字用户ID不匹配。 With NFS, you generally have to insure that your numeric user ids are somehow made the same across all of your systems. 使用NFS,通常必须确保在所有系统上都以相同的方式使数字用户ID相同。 On home/personal systems, user ids tend to assigned haphazardly, without any sort of synchronization, which causes problems with NFS. 在家庭/个人系统上,用户ID往往是随意分配的,没有任何形式的同步,这会导致NFS出现问题。

Since this is a home server, and if you trust everyone that connects to your NFS server, one possible quick-and-easy-and-dirty-and-ugly-and-kludgy fix is to open up permissions and allow everyone and everything to read/write/delete your files (do not do this in an enterprise environment, obviously): 由于这是一台家用服务器,并且如果您信任连接到NFS服务器的每个人,那么一个可能的快速,简单,肮脏,丑陋和混乱的解决方法是开放权限,并允许所有人和所有读/写/删除文件( 这样做在企业环境中,很明显):

On your Ubuntu system, login as jeeves (do not sudo or use any other account), open a terminal window, and run the commands, in the given order: 在您的Ubuntu系统上,以jeeves身份登录(请勿使用sudo或使用任何其他帐户),打开终端窗口,然后按给定顺序运行命令:

 cd /home/jeeves/Documents find . -type d -print0 | xargs -0 chmod 777 find . -type f -print0 | xargs -0 chmod a+rw 

However, this assumes that NFS is set up to allow access to untrusted users (in webmin, "Treat untrusted users as" is set to default, and I'm not sure what this is). 但是,这假定已将NFS设置为允许访问不受信任的用户(在webmin中,将“将不受信任的用户视为”设置为默认值,但我不确定这是什么)。

Note that, with the above commands, the owners of files and directories created by the Mac will appear as numeric users on Ubuntu (because the Ubuntu system will likely not have any users in /etc/passwd corresponding to the Mac numeric ids, Ubuntu will simply display the raw numeric ids). 请注意,使用上述命令,Mac创建的文件和目录的所有者将在Ubuntu上显示为数字用户(因为Ubuntu系统可能在/etc/passwd没有与Mac数字ID对应的任何用户,因此Ubuntu将只需显示原始数字ID)。

Long answer: 长答案:

When you created the jeeves account on your Ubuntu system, Ubuntu assigned it some numeric user id. 在Ubuntu系统上创建jeeves帐户时,Ubuntu为其分配了一些数字用户ID。 When you created your user account on your Mac, the Mac assigned it a numeric user id, which was likely different than the number assigned on the Ubuntu system. 在Mac上创建用户帐户时,Mac为其分配了一个数字用户ID,该ID可能与Ubuntu系统上分配的数字不同。 Note that user names (eg, "jeeves") are a user convenience; 注意,用户名(例如“ jeeves”)是用户的方便; neither Ubuntu nor the Mac use them internally, and instead use user ids. Ubuntu和Mac都不在内部使用它们,而是使用用户ID。 NFS uses these numeric ids to determine ownership/permissions (on the Ubuntu box). NFS使用这些数字ID来确定所有权/权限(在Ubuntu框中)。

  • If the ids match, the "user" permissions are used. 如果ID匹配,则使用“用户”权限。

  • If the ids don't match: 如果ID不匹配:

    • ("Group" permissions can be used, but that's unlikely, and I'm not going to discuss that.) (可以使用“组”权限,但这不太可能,我不再讨论。)

    • The "Other" permissions are used. 使用“其他”权限。 Note that, when creating files/directories, if the (Mac) user id isn't found in the Ubuntu box, you'll generally get files that appear to be owned by a "numeric" owner; 请注意,在创建文件/目录时,如果在Ubuntu框中未找到(Mac)用户ID,则通常会获得看似由“数字”所有者拥有的文件。 the number you see is what the Mac is using, and you see the number because that id doesn't appear in Ubuntu's /etc/passwd . 您看到的数字就是Mac正在使用的数字,您看到的数字是因为该ID未出现在Ubuntu的/etc/passwd

IIRC, Ubuntu uses a umask of 022, which means that only the owner of /home/jeeves/Documents can write/create files and directories; 在IIRC中,Ubuntu使用umask 022,这意味着只有/home/jeeves/Documents的所有者才能写入/创建文件和目录。 everyone else has read-only permissions. 其他所有人都具有只读权限。 Unless you've somehow synchronized user ids between your boxes, you're unlikely to have the same user ids, and so you will get permission issues. 除非您以某种方式在各个框之间同步了用户ID,否则您不太可能拥有相同的用户ID,因此会遇到权限问题。

Since this is a home server, the easiest fix, mentioned above, is to just get rid of security and allow everyone and everything to access your files. 由于这是一台家庭服务器,因此,上面提到的最简单的解决方法是摆脱安全性,并允许所有人和所有人访问您的文件。 Of course, this is distasteful for obvious reasons. 当然,出于显而易见的原因,这令人反感。

The correct fix is to make sure that all user ids are synchronized between all systems, but this can be a problem in a home environment. 正确的解决方法是确保所有用户ID在所有系统之间同步,但这在家庭环境中可能是个问题。 Also, changing user ids once an account has been used is problematic; 同样,一旦使用了帐户,更改用户ID也是有问题的; while this can be done, it has to be done carefully, as you might bork your system. 尽管可以做到这一点,但必须谨慎完成,因为这可能会使您的系统崩溃。 I'm not going to go into details. 我不会详细介绍。

Edit: fixed partial sentence. 编辑:修复部分句子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM