我们有一个工作流程,使用以下命令在 vSphere VM 中部署具有自动 AD 集成的 Ubuntu 20.04.5 LTS:
#!/bin/bash
if [ x$1 == x"precustomization" ]; then
rm -v /home/sysadmin/.bash_history /root/.bash_history
rm -v /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
elif [ x$1 == x"postcustomization" ]; then
echo "P@ssw0rd" | realm join --user "svc.vm.enroll" --computer-ou "OU=UNIX,OU=Managed Servers,DC=corp,DC=example,DC=com" --os-name "Ubuntu Server" corp.example.com
cat <<'EOF' > /tmp/sssd.awk
/^\[sssd\]$/ {
print
print "default_domain_suffix = corp.example.com"
next
}
/^\[domain\/corp.example.com\]$/ {
print
print "ldap_user_ssh_public_key = altSecurityIdentities"
next
}
1
EOF
awk -f /tmp/sssd.awk -i inplace /etc/sssd/sssd.conf
service sssd restart
realm permit --groups "[email protected]"
landscape-config --computer-title "$(hostname)" --account-name standalone --url https://landscape.corp.example.com/message-system --ping-url http://landscape.corp.example.com/ping --script-users=ALL --registration-key="key"
fi
手动运行命令效果很好,但在 vSphere 中执行时,它也能正常工作,但 DNS 中的 PRT 记录设置anhost.
为anhost.corp.example.com
我/etc/hosts
有
127.0.0.1 localhost
127.0.1.1 template-ubuntu-server
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.0.123 anhost.corp.example.com anhost
并且在/etc/resolv.conf
搜索域中也是正确的
手动修复 AD 中的 PRT 记录无法解决问题,每次重启或一段时间后,它都会恢复为错误值
我该如何修复它?