翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
LDAP 認証の使用
Lightweight Directory Access Protocol (LDAP) は、Active Directory または OpenLDAP サーバーのような LDAPとの互換性があるディレクトリサーバープロバイダーで保存されているユーザーやコンピュータなどのリソースに対応するオブジェクトのクエリや変更を行うアプリケーションプロトコルです。使用できます用の LDAP 認証プラグインJupyterHub
このセクションの手順では、LDAP 認証プラグインを使用して LDAP をセットアップおよび有効にする手順を説明します。JupyterHub。このステップはマスターノードのコマンドラインに接続している状態で実行します。詳細については、「マスターノードとノートブックサーバーに接続する」を参照してください。
ホスト IP アドレス、ポート、バインディング名など、LDAP サーバーに関する情報を使用して LDAP 設定ファイルを作成します。
/etc/jupyter/conf/jupyterhub_config.py
を変更して、JupyterHub の LDAP 認証プラグインを有効にします。jupyterhub
コンテナ内で LDAP を設定するスクリプトを作成して実行します。ユーザー用に LDAP をクエリしてから、各ユーザーのコンテナ内でホームディレクトリを作成します。JupyterHubノートブックをホストするにはホームディレクトリが必要です。
再起動するスクリプトを実行するJupyterHub
重要
LDAPを設定する前に、LDAP サーバーとクラスターマスターノードが必要に応じて通信できることを確認するため、ネットワークインフラストラクチャをテストしてください。TLS は通常、単純な TCP 接続でポート 389 を使用します。LDAP 接続が SSL を使用する場合の一般的な SSL の TCP ポートは 636 です。
LDAP 設定ファイルを作成する
以下の例では、次のプレースホルダー設定の値を使用します。これらの値を実装と一致するパラメータに置き換えます。
LDAP サーバーはバージョン 3 を実行していて、ポート 389 で使用可能になっています。これは標準的な LDAP の非 SSL ポートです。
ベース識別子名 (DN) は
dc=example, dc=org
です。
テキストエディタを使用して、次のようなコンテンツを含む ldap.confhost
を IP アドレスまたは LDAP サーバーの解決可能なホスト名に置き換えます。
base dc=example,dc=org uri ldap://
host
ldap_version 3 binddn cn=admin
,dc=example
,dc=org
bindpw admin
JupyterHub の LDAP 認証プラグインを有効にする
テキストエディタを使用して /etc/jupyter/conf/jupyterhub_config.py
ファイルを変更し、次のような ldapauthenticatorhost
を IP アドレスまたは LDAP サーバーの解決可能なホスト名に置き換えます。この例では、ユーザーオブジェクトが people
という組織単位 (ou) にあり、先に ldap.conf
を使って確立した識別名のコンポーネントを使用しているものとします。
c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator' c.LDAPAuthenticator.use_ssl = False c.LDAPAuthenticator.server_address = '
host
' c.LDAPAuthenticator.bind_dn_template = 'cn={username},ou=people
,dc=example
,dc=org
'
コンテナ内で LDAP を設定する
テキストエディタを使用して、次のコンテンツを含む bash スクリプトを作成します。
#!/bin/bash # Uncomment the following lines to install LDAP client libraries only if # using Amazon EMR release version 5.14.0. Later versions install libraries by default. # sudo docker exec jupyterhub bash -c "sudo apt-get update" # sudo docker exec jupyterhub bash -c "sudo apt-get -y install libnss-ldap libpam-ldap ldap-utils nscd" # Copy ldap.conf sudo docker cp ldap.conf jupyterhub:/etc/ldap/ sudo docker exec jupyterhub bash -c "cat /etc/ldap/ldap.conf" # configure nss switch sudo docker exec jupyterhub bash -c "sed -i 's/\(^passwd.*\)/\1 ldap/g' /etc/nsswitch.conf" sudo docker exec jupyterhub bash -c "sed -i 's/\(^group.*\)/\1 ldap/g' /etc/nsswitch.conf" sudo docker exec jupyterhub bash -c "sed -i 's/\(^shadow.*\)/\1 ldap/g' /etc/nsswitch.conf" sudo docker exec jupyterhub bash -c "cat /etc/nsswitch.conf" # configure PAM to create home directories sudo docker exec jupyterhub bash -c "echo 'session required pam_mkhomedir.so skel=/etc/skel umask=077' >> /etc/pam.d/common-session" sudo docker exec jupyterhub bash -c "cat /etc/pam.d/common-session" # restart nscd service sudo docker exec jupyterhub bash -c "sudo service nscd restart" # Test sudo docker exec jupyterhub bash -c "getent passwd" # Install ldap plugin sudo docker exec jupyterhub bash -c "pip install jupyterhub-ldapauthenticator"
マスターノードにスクリプトを保存し、マスターノードのコマンドラインから実行します。たとえば、configure_ldap_client.sh
として保存されているスクリプトでファイルを実行可能にします。
chmod +x configure_ldap_client.sh
スクリプトを実行します。
./configure_ldap_client.sh
Active Directory に属性を追加する
各ユーザーを検索してデータベースに適切なエントリを作成するには、JupyterHubドッカーコンテナには、Active Directory内の対応するユーザーオブジェクトに次のUNIXプロパティが必要です。詳細については、記事「Clarification regarding the status of identity management for Unix (IDMU) and NIS server role in Windows Server 2016 technical preview and beyond
homeDirectory
これは、ユーザーのホームディレクトリへの場所 (通常は
/home/
) です。username
gidNumber
これは、別のユーザーがすでに使用していない 60000 より大きい値です。使用中の GID については、
etc/passwd
ファイルを確認してください。uidNumber
これは、別のグループがすでに使用していない 60000 より大きい値です。使用中の UID については、
etc/group
ファイルを確認してください。uid
これは
username
と同じです。
ユーザーのホームディレクトリを作成する
ユーザーを認証しインスタンスデータを保存するため、JupyterHub はコンテナ内のホームディレクトリを必要とします。次の例は LDAP ディレクトリのshirley と diego という 2 人のユーザーを示しています。
まず、次の例のように ldapsearchhost
は LDAP サーバーの IP アドレスまたは解決可能なホスト名に置き換わります。
ldapsearch -x -H ldap://
host
\ -D "cn=admin,dc=example,dc=org" \ -w admin \ -b "ou=people,dc=example,dc=org" \ -s sub \ "(objectclass=*)" uidNumber gidNumber
ldapsearch
コマンドが shirley と diego といった 2 人のユーザーに見られるような LDIF 形式のレスポンスを返します。
# extended LDIF # LDAPv3 # base <ou=people,dc=example,dc=org> with scope subtree # filter: (objectclass=*) # requesting: uidNumber gidNumber sn # people, example.org dn: ou=people,dc=example,dc=org # diego, people, example.org dn: cn=diego,ou=people,dc=example,dc=org sn: B uidNumber: 1001 gidNumber: 100 # shirley, people, example.org dn: cn=shirley,ou=people,dc=example,dc=org sn: A uidNumber: 1002 gidNumber: 100 # search result search: 2 result: 0 Success # numResponses: 4 # numEntries: 3
レスポンスからの情報を使用し、コンテナ内のコマンドを実行して各ユーザーの共通名 (cn
) にホームディレクトリを作成します。uidNumber
と gidNumber
を使用して、そのユーザーのホームディレクトリの所有権を修正します。その操作を次の例のコマンドがユーザーの shirley
に行います。
sudo docker container exec jupyterhub bash -c "mkdir /home/
shirley
" sudo docker container exec jupyterhub bash -c "chown -R $uidNumber /home/shirley
" sudo docker container exec jupyterhub bash -c "sudo chgrp -R $gidNumber /home/shirley
"
注記
の LDAP オーセンティケーターJupyterHubローカルユーザーの作成はサポートしていません。詳細については、「LDAP authenticator configuration note on local user creation
ローカルユーザーを手動で作成するには、次のコマンドを使用します。
sudo docker exec jupyterhub bash -c "echo '
shirley
:x:$uidNumber:$gidNumber::/home/shirley
:/bin/bash' >> /etc/passwd"
を再起動しますJupyterHub容器
以下のコマンドを実行して、jupyterhub
コンテナを再起動します。
sudo docker stop jupyterhub sudo docker start jupyterhub