bug: setfacl: Option -m: Invalid argument near character 3
原因 dirsrv 启动前会执行 /usr/sbin/ds_systemd_ask_password_acl /etc/dirsrv/slapd-
执行失败。
表面上看, 似乎是文件的权限设置不对。
进一步研究,发现是脚本获取用户名的时候,取值不对。
# 查看正常的权限
$ getfacl /etc/dirsrv/slapd-/dse.ldif
getfacl: Removing leading '/' from absolute path names
# file: etc/dirsrv/slapd-/dse.ldif
# owner: dirsrv
# group: dirsrv
user::rw-
group::---
other::---
# 文件 dse.ldif 内容:
nsslapd-localuser: dirsrv
# 获取用户 id 逻辑
DS_USER=`grep 'nsslapd-localuser: ' dse.ldif | awk '{print $2}'`
#正常值: DS_USER=dirsrv
# 获取失败:
Binary file (standard input) matches
DS_USER=file
# 异常的原因: grep dse.idif 时输出为 "Binary file (standard input) matches"
# grep 认为这个 67K 的文件为二进制而导致后续的一系列失败
# 修复
DS_USER=`grep -a 'nsslapd-localuser: ' dse.ldif | awk '{print $2}'`
CentOS 7.7 新坑: Error org.freedesktop.DBus.Error.NoReply
在 CentOS7.7 服务器上,安装新服务时,有很大概率报以上错误,导致安装失败,
检测方法:
dbus-send --system --type=method_call --print-reply --dest=org.fedorahosted.certmonger /org/fedorahosted/certmonger org.freedesktop.DBus.Introspectable.Introspect
如果此命令很快返回XML输出,则说明 certmonger 服务正常,可以进行服务安装。
mkdir -p /usr/lib/systemd/system/certmonger.service.d
cat > /usr/lib/systemd/system/certmonger.service.d/wait-for-ready.conf <<-EOF
[Service]
ExecStartPost=/bin/bash -c 'while ! dbus-send --system --type=method_call --print-reply --dest=org.fedorahosted.certmonger /org/fedorahosted/certmonger org.freedesktop.DBus.Introspectable.Introspect > /dev/null ; do sleep 5 ; done'
TimeoutSec=300
LimitNOFILE=1024
EOF
systemctl daemon-reload
systemctl restart certmonger
dbus-send --system --type=method_call --print-reply --dest=org.fedorahosted.certmonger /org/fedorahosted/certmonger org.freedesktop.DBus.Introspectable.Introspect
重装 freeipa 服务器端
#Master
host="hostname.domain.com"
ip="1.2.3.4"
sshport=2222
# Master del host
ipa-replica-manage del $host -p 'LDAP_PWD'
ipa host-del $host
# Master prepare ssl
ipa-replica-prepare $host --ip-address $ip --no-reverse -p 'LDAP_PWD
# dest host to uninstall freeipa server
ipa-server-install --uninstall
# Master copy
scp -P $sshport /var/lib/ipa/replica-info-$host.gpg root@$host:/var/lib/ipa/
# dest host install
报错:
dbus.proxies: ERROR Introspect error on :1.166:/org/fedorahosted/certmonger: dbus.exceptions.DBusException
原因: selinux 限制了,禁用selinux 并重启 dbus服务
test -f /etc/selinux/config && setenforce 0 && sed -i 's/^SELINUX=.*$/SELINUX=disabled/g' /etc/selinux/config
systemctl restart dbus.socket
systemctl restart dbus.service
文件找不到 /usr/share/pki/server/common/lib/symkey.jar (/usr/lib/java/symkey.jar)
yum install -y pki-symkey
无法启动
journalctl -u [email protected]
WARNING: changelog: entry cache size 2097152 B is less than db size 210132992 B; We recommend to increase the entry cache size nsslapd-cachememsize
处理步骤
- 尝试各种恢复手段,均有问题。 最后基于 freeipa 的 Multi-Master 架构,重新初始化故障节点解决问题。
- 故障服务器开启 iptables ,只允许 freeipa 集群间的ip 访问,避免其他服务器访问到故障的 dns 服务
- 故障服务器卸载 freeipa,重新配置,作为新节点加到正常节点
- 测试,无问题后,取消 iptables
webui 偶尔无法登录,提示已登录
处理步骤
- 每天半夜执行 ipactl restart
升级到 4.5.0 版本,无法启动
- 内核参数启用 ipv6
缺少 CA 文件 /etc/ipa/ca.crt
从 /etc/pki/ca-trust/source/ipa.p11-kit 文件提取
cat /etc/pki/ca-trust/source/ipa.p11-kit | grep 'BEGIN' -A21
test -f /etc/ipa/ca.crt || cat /etc/pki/ca-trust/source/ipa.p11-kit | grep 'BEGIN' -A21 > /etc/ipa/ca.crt
升级到 CentOS 7.5,webui 无法登录,提示“未知错误”。 /var/lib/ipa-client/pki 无任何文件。
检查磁盘空间
查看是否缺少 CA 文件 /etc/ipa/ca.crt
chown ipaapi:ipaapi -Rv /var/run/ipa/ccaches
cp /etc/ipa/ca.crt /var/lib/ipa-client/pki/ca-bundle.pem
cp /etc/ipa/ca.crt /var/lib/ipa-client/pki/kdc-ca-bundle.pem
ipactl restart
# change PKINIT to disabled
ipa-pkinit-manage status
ipa-pkinit-manage disable
ipactl restart
ubuntu + freeipa can't mkhomedir
sed -i -r -e 's/Default:\s\w+/Default: yes/;' /usr/share/pam-configs/mkhomedir
sed -i '/mkhomedir/d' /var/lib/pam/seen
pam-auth-update --package
升级 freeipa 导致 ssh 无法启动
报错:AuthorizedKeysCommand set without AuthorizedKeysCommandUser
解决: AuthorizedKeysCommandUser nobody 这一行加入到 /etc/ssh/sshd_config,再重启 ssh 服务。
Failed to start pki-tomcatd Service
日志报错 /usr/share/pki/server/common/lib/symkey.jar 文件不存在
yum install pki-symkey
sudo certutil -M -t ',,P' -d /etc/pki/pki-tomcat/alias -n 'auditSigningCert cert-pki-ca'
https://osric.com/chris/accidental-developer/2017/10/freeipa-failed-to-start-pki-tomcatd-service/
Ubuntu 18.04 freeclient 无法认证, 原因是 /etc/nsswitch.conf 文件没有 sss 的参数。
sed -i 's/^passwd:.*$/passwd: compat systemd sss/g' /etc/nsswitch.conf
sed -i 's/^group:.*$/group: compat systemd sss/;' /etc/nsswitch.conf
sed -i 's/^shadow:.*$/shadow: compat sss/;' /etc/nsswitch.conf
sed -i 's/^services:.*$/services: db files sss/;' /etc/nsswitch.conf
sed -i 's/^netgroup:.*$/netgroup: nis sss/;' /etc/nsswitch.conf
数据备份恢复
ipa-backup
rsync -pav -e "ssh -p 22" /var/lib/ipa/backup/ipa-full-2019-05-09-18-22-27 [email protected]:/var/lib/ipa/backup/
# new server
change host in header file
ipa-restore --log-file=restore.log /var/lib/ipa/backup/ipa-full-2019-05-09-18-22-27 -p 'ldap-pwd'
ipaserver 新增节点失败
原因: pip 依赖包的 jwcrypto 包名写错了,囧。。。
sed -i s/jwcrpyto/jwcrypto/g /usr/lib/python2.7/site-packages/ipaserver-4.6.4-py2.7.egg-info/requires.txt
ipa-server 集群(不部署dns)搭建步骤
# 1. 安装第一个 ipa-server
yum -y install ipa-server python2-ipaserver
LDAP_PWD=xxxx
ADMIN_PWD=xxxx
ipa-server-install -p $LDAP_PWD -a $ADMIN_PWD --hostname=$(hostname -f) --mkhomedir -U -r DOMAIN.COM -n domiain.com --ssh-trust-dns --allow-zone-overlap
#2. 设置 DNS,将 dns 解析记录指向 第一个 ipa-server
ipa a 1.2.3.4
_kerberos TXT DOMAIN.COM
_kerberos-master._tcp SRV 0 100 88 ipa
_kerberos-master._udp SRV 0 100 88 ipa
_kerberos._tcp SRV 0 100 88 ipa
_kerberos._udp SRV 0 100 88 ipa
_kpasswd._tcp SRV 0 100 464 ipa
_kpasswd._udp SRV 0 100 464 ipa
_ldap._tcp SRV 0 100 389 ipa
_ntp._udp SRV 0 100 123 ipa
#3. 安装第二个和第N个 ipa-server
yum -y install ipa-server python2-ipaserver
ipa-client-install
ipa-replica-install -w $ADMIN_PWD
ipa-ca-install -p $LDAP_PWD
ipa-server 集群(包含部署dns)搭建步骤
# 1. 安装第一个 ipa-server
yum -y install ipa-server python2-ipaserver ipa-server-dns bind bind-dyndb-ldap
LDAP_PWD=xxxx
ADMIN_PWD=xxxx
ipa-server-install -p $LDAP_PWD -a $ADMIN_PWD --hostname=$(hostname -f) --mkhomedir -U -r DOMAIN.COM -n domain.com --ssh-trust-dns --allow-zone-overlap --setup-dns --forwarder=119.29.29.29 --forwarder=114.114.114.114
#2. 安装第二个和第N个 ipa-server
yum -y install ipa-server python2-ipaserver ipa-server-dns bind bind-dyndb-ldap
ipa-client-install
ipa-replica-install -w $ADMIN_PWD -p $LDAP_PWD --setup-ca --setup-dns --forwarder=119.29.29.29 --forwarder=114.114.114.114 --no-reverse --skip-conncheck --allow-zone-overlap --no-host-dns --unattended
IPA 服务器作为 linux ldap 认证
authconfig --enableldap --enableldapauth --enablemkhomedir --disablenis --enablecache --enablelocauthorize --enableforcelegacy --disablesssd --disablesssdauth --updateall --ldapserver=ipa.domian.com --ldapbasedn="cn=accounts,dc=domain,dc=com"
ref:
https://bgstack15.wordpress.com/2017/06/26/enabling-mkhomedir-on-ubuntu-for-freeipa/
https://bugs.launchpad.net/ubuntu/+source/pam/+bug/682662/comments/8