CentOS 6 + LDAP + NFS。文件所有权卡在“没人”上


11

几天来,我一直在尝试在CentOS 6上进行LDAP身份验证和NFS导出的主目录。现在,我可以使用LDAP中的用户名和密码登录到客户端计算机了。在客户端上,/ home和/ opt通过NFS挂载在fstab中。但是,/ opt和/ home中的每个文件都由nobody:nobody客户端上的(uid:99,gid:99)拥有。

但是我的uid和gid似乎设置正确:

-bash-4.1$ id
uid=3000(myusername) gid=3000(employees) groups=3000(employees)

我还能检查什么?这是我客户端上的一些配置文件:

/etc/nsswitch.conf

passwd:     files sss
shadow:     files sss
group:      files sss

hosts:      files dns

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   files sss

publickey:  nisplus

automount:  files ldap
aliases:    files nisplus

/etc/sssd/sssd.conf

[sssd]
config_file_version = 2
services = nss, pam

domains = default
[nss]

[pam]


[domain/default]
auth_provider = ldap
ldap_id_use_start_tls = True
chpass_provider = ldap
cache_credentials = True
krb5_realm = EXAMPLE.COM
ldap_search_base = dc=mycompany,dc=com
id_provider = ldap
ldap_uri = ldaps://server.subdomain.mycompany.com
krb5_kdcip = kerberos.example.com
ldap_tls_cacertdir = /etc/openldap/cacerts

# Configure client certificate auth.
ldap_tls_cert = /etc/openldap/cacerts/client.pem
ldap_tls_key = /etc/openldap/cacerts/client.pem
ldap_tls_reqcert = demand

/ etc / fstab

/dev/mapper/vg_main-lv_root /                       ext4    defaults        1 1
UUID=4e43a15d-4dc0-4836-8fa6-c3445fde756c /boot                   ext4    defaults        1 2
/dev/mapper/vg_main-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
storage1:/nas/home  /home  nfs   soft,intr,rsize=8192,wsize=8192
storage1:/nas/opt  /opt  nfs   soft,intr,rsize=8192,wsize=8192

authconfig输出:

[root@test1 ~]# authconfig --test
caching is disabled
nss_files is always enabled
nss_compat is disabled
nss_db is disabled
nss_hesiod is disabled
 hesiod LHS = ""
 hesiod RHS = ""
nss_ldap is enabled
 LDAP+TLS is enabled
 LDAP server = "ldaps://server.subdomain.mycompany.com"
 LDAP base DN = "dc=mycompany,dc=com"
nss_nis is disabled
 NIS server = ""
 NIS domain = ""
nss_nisplus is disabled
nss_winbind is disabled
 SMB workgroup = ""
 SMB servers = ""
 SMB security = "user"
 SMB realm = ""
 Winbind template shell = "/bin/false"
 SMB idmap uid = "16777216-33554431"
 SMB idmap gid = "16777216-33554431"
nss_sss is disabled by default
nss_wins is disabled
nss_mdns4_minimal is disabled
DNS preference over NSS or WINS is disabled
pam_unix is always enabled
 shadow passwords are enabled
 password hashing algorithm is sha512
pam_krb5 is disabled
 krb5 realm = "EXAMPLE.COM"
 krb5 realm via dns is disabled
 krb5 kdc = "kerberos.example.com"
 krb5 kdc via dns is disabled
 krb5 admin server = "kerberos.example.com"
pam_ldap is enabled
 LDAP+TLS is enabled
 LDAP server = "ldaps://server.subdomain.mycompany.com"
 LDAP base DN = "dc=mycompany,dc=com"
 LDAP schema = "rfc2307"
pam_pkcs11 is disabled
 use only smartcard for login is disabled
 smartcard module = ""
 smartcard removal action = ""
pam_fprintd is enabled
pam_winbind is disabled
 SMB workgroup = ""
 SMB servers = ""
 SMB security = "user"
 SMB realm = ""
pam_sss is disabled by default
 credential caching in SSSD is enabled
 SSSD use instead of legacy services if possible is enabled
pam_cracklib is enabled (try_first_pass retry=3 type=)
pam_passwdqc is disabled ()
pam_access is disabled ()
pam_mkhomedir or pam_oddjob_mkhomedir is enabled ()
Always authorize local users is enabled ()
Authenticate system accounts against network services is disabled

如果您希望NAS与来宾看到相同的ID,是否也不需要将NAS连接到LDAP?
Yanick Girouard 2012年

亚尼克,感谢您的答复。我的NAS单元实际上只是另一个运行NFS守护程序的CentOS机器。它的配置与其他LDAP客户端相同,并且存在相同的“ nobody”问题。
jamieb'2

Answers:


22

为Google搜索者添加的一条注释-我们遇到了同样的问题,无论我们做什么,nfs挂载都无法正确映射用户ID。

idmapd问题已从错误的配置中缓存了不正确的ID,并且无法修复该配置对它进行排序。

解决此问题的centos命令是nfsidmap -c(清除缓存)。

希望这可以帮助一些绝望的搜索者。


18

解决了!

/var/log/messages当我尝试从远程客户端挂载导出时,我偶然发现这行出现在我的NFS服务器上:

Feb 28 15:54:02 storage1 rpc.idmapd[1651]: nss_getpwnam: name 'nobody' does not map into domain 'localdomain'

这使我看了以下的前几行/etc/idmapd.conf

[General]
#Verbosity = 0
# The following should be set to the local NFSv4 domain name
# The default is the host's DNS domain name.
#Domain = local.domain.edu

然后,我Domain=subdomain.mycompany.com在注释掉的“域”行下添加了内容。保存,退出然后运行/etc/init.d/rpcidmapd restart/etc/init.d/nfs restart


这对我有帮助。我将注意到,我必须在服务器和所有客户端上都进行此更改。
迈克尔·汉普顿


0

您的NFS服务器是否正在运行Centos / RHEL 5?

如果是这样,它将导出NFSv3。NFSv4现在是Centos6(和最近的Ubuntu变体)的默认设置。

快速解决方法是在/ etc / fstab的安装选项中添加“ vers = 3”。

例如

//10.0.0.1:/home / home nfs默认值,vers = 3,rw,noatime 0 0


谢谢你的建议。LDAP服务器,客户端和NFS服务器都在运行CentOS 6.2。当我尝试使用版本3选项安装它时,在客户端上出现权限拒绝错误。
jamieb 2012年

您是否以root用户身份对此进行测试?阅读linuxtopia.org/online_books/rhel6/rhel_6_storage_admin/…的一些有用的参考。值得在NFS服务器上启用no_root_squash。
NcA 2012年

解决了(请参见下面的答案)!感谢您让我更多地考虑NFS,因为我主要关注LDAP。
jamieb 2012年

0

映射为“ nobody”的所有内容听起来都像打开了all_squash。

看一眼:

http://www.centos.org/docs/5/html/Deployment_Guide-zh-CN/s1-nfs-server-config-exports.html

并确认NFS服务器的/ etc / exports文件没有无意间挤压UID。“ no_all_squash”应该是默认值,但您可以尝试显式设置它并查看会发生什么。


1
不幸的是,没有运气。但是有趣的是,mount storage1:/nas/opt /mnt/test在独立客户端上仍然给我“没人”的问题,但是NFS服务器上的同一命令可以正常工作。我希望我知道这是NFS还是SSSD / NSS问题。
jamieb'2

0

对我来说,解决方法是确保本地计算机的DNS记录存在。如果还存在反向查询记录,则也有帮助。结果,noot用户和组被替换为root。这有多简单?!?PS记住,一旦创建了DNS记录,便要重启本地计算机。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.