title: How to connect spark application to secure HBase with Kerberos
body: <p>I`m trying to connect a Spark application to HBase with Kerberos enabled. Spark version is 1.5.0, CDH 5.5.2 and it's executed in yarn cluster mode.</p>
  
  <p>When HbaseContext is initialized, it throws this error:</p>
  
  <blockquote>
    <p>ERROR ipc.AbstractRpcClient: SASL authentication failed. The most likely cause is missing or invalid credentials. Consider 'kinit'.
    javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]</p>
  </blockquote>
  
  <p>I have tried to do the authentication in the code, adding:</p>
  
  <pre><code>UserGroupInformation.setConfiguration(config)
  UserGroupInformation.loginUserFromKeytab(principalName, keytabFilename)
  </code></pre>
  
  <p>I distribute the keytab file with --files option in spark-submit.
  Now, the error is:</p>
  
  <blockquote>
    <p>java.io.IOException: Login failure for usercomp@COMPANY.CORP from keytab krb5.usercomp.keytab: javax.security.auth.login.LoginException: Unable to obtain password from user
    ...</p>
    
    <p>Caused by: javax.security.auth.login.LoginException: Unable to obtain password from user
    at com.sun.security.auth.module.Krb5LoginModule.promptForPass(Krb5LoginModule.java:856)</p>
  </blockquote>
  
  <p>Is this the way to connect to Kerberized HBase from a Spark app? </p>