centos 如何让Chef查找Active Directory用户?

ebdffaop  于 2022-11-07  发布在  其他
关注(0)|答案(3)|浏览(176)

错误:

Chef::Exceptions::UserIDNotFound
--------------------------------
cannot determine user id for 'builduser', does the user exist on this system?

这是我的(修剪)厨师食谱:

if node['platform'] == 'centos'
  package 'yum-utils'
  execute 'yum-config-manager --enable cr'
end

include_recipe "python::source"

...

## Setup key for jenkins... https://supermarket.chef.io/cookbooks/ssh_authorized_keys

ssh_authorize_key 'builduser@supermarket.com' do
    key 'AAAAB3Nz...hiOQ=='
    user 'builduser'
    group 'builduser'
end

此用户 * 不是 * 由该配方创建的,但已存在于此CentOS虚拟机连接到的Active Directory中。
有人知道如何告诉厨师去阅读这从活动目录?
先谢谢你

khbbv19g

khbbv19g1#

您可能遇到了可怕的“nsswitch.conf reload”问题。它第二次工作还是总是失败?如果它第二次工作,可能是因为/etc/nsswitch.conf只是在Chef运行的早些时候更新的,并且由于libc缓存nsswitch数据库配置的方式,这些更改在Chef进程重新启动之前是不可见的。如果它总是失败,请检查计算机是否具有正确的nsswitch配置以使AD用户可见。仅在PAM上链接到AD不足以使用户条目正常工作。

lrl1mhuk

lrl1mhuk2#

我的解决方法是创建root拥有的文件资源,然后将其chown给用户。不知怎么的... chown似乎对AD没有问题。

file '/home/orgz_test/builduser/.ssh/authorized_keys' do
  content 'ssh-rsa AAAAB3Nz...hiOQ== builduser@supermarket.com'
  mode '0644'
end

# user and group setting in 'file' or 'directory' does not work... so, do it manually

bash "Change ownership" do
    user "root"
    group "root"
    code <<-EOC
        chown builduser /home/orgz_test/builduser/.ssh/authorized_keys
        chgrp builduser_g /home/orgz_test/builduser/.ssh/authorized_keys
        chmod 600 /home/hedgeservtest.com/cashmgmt/.ssh/authorized_keys
    EOC
end

不是最漂亮的解决方案...但很有效。

n1bvdmb6

n1bvdmb63#

1.将用户密钥重定向到不同区域;/etc/ssh/keys/例如:

--- /etc/ssh/sshd_config
+++ /etc/ssh/sshd_config
@@ -41,1 +41,1 @@
-AuthorizedKeysFile     .ssh/authorized_keys
+AuthorizedKeysFile     .ssh/authorized_keys /etc/ssh/keys/keys-%u

编码类似


# bad pseudocoding; at own risk!

include_attribute 'openssh::default'
default['openssh']['server']['authorized_keys_file'] += ' /etc/ssh/keys/keys-%u'

1.将它们更改为root.root和400,因为只有sshd需要读取它们
1.反正都是厨师管


# bad pseudocoding; at own risk!

directory /etc/ssh/keys
keys.each do |user,strarrkeys|

  file "/etc/ssh/keys/keys-#{user}" do  # make this DRYer for added credit
    content strarrkeys.join("\n")
    user  'root'
    group 'root'
    mode  '400'  #600?
    action strarrkeys.empty? ? :delete : :create
  end
end

1.米勒时间

相关问题