--- title: "Secure Hadoop への外部サービスからのアクセス" slug: "secure-hadoop-use-7" updated: 2026-09-17T09:25:49Z published: 2026-09-17T09:25:49Z canonical: "guide.ncloud-docs.com/secure-hadoop-use-7" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Secure Hadoop への外部サービスからのアクセス VPC環境で利用できます。 外部サービス(例: Jupyter Notebook、NKS、一般サーバなど)から Secure Hadoopにアクセスするには、当該環境に Kerberos設定ファイルの構成と事前認証手続きが必要です。 #### 1. `etc/krb5.conf` 設定 - 外部サーバや VMから Secure Hadoopにアクセスするには、Kerberos環境情報を設定する必要があります。 - Secure Hadoopのエッジノードから `/etc/krb5.conf` ファイル内容をコピーします。 - 外部サーバや VMの /etc/krb5.confにコピーした内容を保存し、Kerberos Realmと KDC情報を設定します。 #### 2. kkeytabまたは kinitによる認証実行 - Secure Hadoopにアクセスするソースコードを実行する前に Kerberos認証を実行するように設定します。 - keytab認証方式のユースケース ``` import subprocess def kinit_with_keytab(principal: str, keytab_path: str): try: result = subprocess.run( ["kinit", "-kt", keytab_path, principal], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) print(f"[INFO] kinit成功: {principal}") except subprocess.CalledProcessError as e: print(f"[ERROR] kinit失敗: {e.stderr.decode().strip()}") # 使用例 principal = "user1@USER.GUIDE" keytab_path = "/tmp/user1.keytab" kinit_with_keytab(principal, keytab_path) ``` - パスワードログイン方式のユースケース ``` import subprocess import getpass def kinit_with_password(principal: str): try: # ユーザーにパスワードを入力させる(非表示処理) password = getpass.getpass(prompt=f"{principal}の Kerberosパスワード: ") # subprocessで kinitを実行 process = subprocess.run( ["kinit", principal], input=password.encode(), # パスワードを stdinに転送 stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True ) print(f"[INFO] kinit成功: {principal}") except subprocess.CalledProcessError as e: print(f"[ERROR] kinit失敗: {e.stderr.decode().strip()}") # 使用例 principal = "user1@USER.GUIDE" kinit_with_password(principal) ```