以下步骤对我有用。
首先,我安装了 jupyterhub LDAP 身份验证器。
pip3 install jupyterhub-ldapauthenticator
安装后,我编辑了配置文件。
nano /etc/jupyterhub/jupyterhub_config.py
配置如下所示:
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
c.LDAPAuthenticator.server_hosts = ['ldap://ldap.example.com:389']
c.LDAPAuthenticator.bind_user_dn = 'uid=ldapbind,cn=users,dc=ldap,dc=example,dc=com‘
c.LDAPAuthenticator.bind_user_password = ‘Password’
c.LDAPAuthenticator.user_search_base = 'cn=users,dc=ldap,dc=example,dc=com‘
c.LDAPAuthenticator.user_search_filter = '(&(objectClass=posixAccount)(uid={username}))'
c.LDAPAuthenticator.username_pattern = '[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?'
c.LDAPAuthenticator.create_user_home_dir = True
c.LDAPAuthenticator.create_user_home_dir_cmd = ['mkhomedir_helper']
在下一步中,我安装了以下 LDAP 包。
sudo apt-get install libnss-ldap libpam-ldap nscd
在安装过程中,您可以对配置进行必要的更改。安装完成后需要重新配置包,因为需要修改密码加密。
sudo dpkg-reconfigure ldap-auth-config
接下来,我更改了配置文件 ldap.conf。
nano /etc/ldap/ldap.conf
发件人:
#BASE dc=unixmen,dc=local
#URI ldap://192.168.1.100
收件人:
BASE dc=ldap,dc=example,dc=com
URI ldap://ldap.example.com
我编辑的第二个配置文件是 nsswitch.conf。 ldap需要加四次。
passwd: compat ldap
group: compat ldap
shadow: compat ldap
netgroup: ldap
修改后需要重启服务。
systemctl restart nscd