ubuntuからLDAPに接続してみる
*rootアカウントを有効にして作業してます
「libpam-ldap」「nscd」をインストールするのだが、ubuntu 18.04では既定でインストールできないみたい。
「/etc/apt/sources.list」を修正してmain以外にも「universe」を追記する
root@ubuntu:~# cat /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
root@ubuntu:~# apt updateその後にパッケージをインストールする
root@ubuntu:~# apt install libpam-ldap ldap-utils nscd途中「Configuring ldap-auth-config」画面が現れる。
LDAPサーバのアドレスを問われるので、それを入力してOKリンクを押下する

次にベースDNが問われ、値を入力してOKリンクを押下する

LDAPのバージョンを問われるが、「3」を選ぶ

次の画面は「No」を選び

次も「No」を選ぶ

インストールと共に設定も行ってくれた
前述の操作で下記が作成される。
root@ubuntu:~# grep -v -e '^\s*#' -e '^\s*$' /etc/ldap.conf
base dc=sybyl,dc=local
uri ldap://192.168.0.81/
ldap_version 3
pam_password md5
root@ubuntu:~#そのほかに「nsswitch.conf」を修正します
root@ubuntu:~# diff -u /etc/nsswitch.conf.orig /etc/nsswitch.conf
--- /etc/nsswitch.conf.orig 2018-10-07 02:09:53.244122015 +0000
+++ /etc/nsswitch.conf 2018-10-07 02:10:22.071942307 +0000
@@ -4,9 +4,9 @@
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
-passwd: compat systemd
-group: compat systemd
-shadow: compat
+passwd: compat ldap
+group: compat ldap
+shadow: compat ldap
gshadow: files
hosts: files dns
@@ -17,4 +17,4 @@
ethers: db files
rpc: db files
-netgroup: nis
+netgroup: nis ldap
root@ubuntu:~#修正が終わったら nscd を再起動させます。
root@ubuntu:~# systemctl restart nscdこれで終了。
getentコマンドかidコマンドで確認する
root@ubuntu:~# getent passwd foo
foo:x:3000:2001:foo sybyl:/home/foo:/bin/bash
root@ubuntu:~# id foo
uid=3000(foo) gid=2001(xray) groups=2001(xray)
稼働プログラムはnscdのみ?
root@ubuntu:~# systemctl status nscd
● nscd.service - Name Service Cache Daemon
Loaded: loaded (/lib/systemd/system/nscd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-10-07 02:30:21 UTC; 1min 34s ago
Process: 1109 ExecStart=/usr/sbin/nscd (code=exited, status=0/SUCCESS)
Main PID: 1131 (nscd)
Tasks: 10 (limit: 4634)
CGroup: /system.slice/nscd.service
mq1131 /usr/sbin/nscd
:
root@ubuntu:~#sssdを使ってLDAPサーバに繋げてみる
root@ubuntu:~# apt install sssd sssd-ldapCentOSで提供されるようなauthconfigが無いので手動で「/etc/sssd/sssd.conf」を作成する
root@ubuntu:~# cat /etc/sssd/sssd.conf
[domain/default]
autofs_provider = ldap
cache_credentials = True
ldap_search_base = dc=sybyl,dc=local
id_provider = ldap
auth_provider = ldap
chpass_provider = ldap
ldap_uri = ldap://192.168.0.81/
ldap_id_use_start_tls = False
ldap_tls_cacertdir = /etc/openldap/cacerts
ldap_tls_reqcert = never
[sssd]
services = nss, pam, autofs
domains = default
[nss]
homedir_substring = /home
[pam]
[sudo]
[autofs]
[ssh]
[pac]
[ifp]
[secrets]
[session_recording]
root@ubuntu:~#sssd.confはファイルパーミッションを0600に変更して、sssdを再起動します
*nsswitch.confは sssd のパッケージをインストールしたときに更新してくれている
root@ubuntu:~# chmod 600 /etc/sssd/sssd.conf
root@ubuntu:~# systemctl restart sssdこれでLDAPサーバのデータを参照できるようになる
root@ubuntu:~# getent passwd foo
foo:*:3000:2001:foo sybyl:/home/foo:/bin/bash
root@ubuntu:~#別のマシンからのsshログインも確認できた