Kerberos java to hive keytab authentication, login

2019-05-14 03:16发布

问题:

I am trying to get kerberos keytab authentication work from java to Hive and not finding solution to fix the issue.

    org.apache.hadoop.conf.Configuration conf = new   
       org.apache.hadoop.conf.Configuration();
    conf.set("hadoop.security.authentication", "kerberos");
    conf.set(HiveClientFactory.HIVE_METASTORE_URIS,"thrift://{URL}");
    UserGroupInformation.setConfiguration(conf);
    UserGroupInformation.loginUserFromKeytab(krbPrincipal, keyTabPath);

java.io.IOException: Login failure for {krbPrincipal} from keytab {keyTabPath} at org.apache.hadoop.security.UserGroupInformation.loginUserFromKeytab(UserGroupInformation.java:855)

Caused by: javax.security.auth.login.LoginException: Unable to obtain password from user

at com.sun.security.auth.module.Krb5LoginModule.promptForPass(Krb5LoginModule.java:789) at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:654)

I would really appreciate some insight to help resolve this.