Reply
New Contributor
Posts: 1
Registered: ‎03-21-2017

Accessing HDFS on Cloudera with Java and Kerberos Keytab from Windows

[ Edited ]

Hi all,

I'm trying to connect to my HDFS instance running on Cloudera. My first step was enabling Kerberos and creating Keytabs (as shown here). In the next step i would like to authenticate with a keytab using eclipse on Windows.

 

 

Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://cloudera:8020");
conf.set("hadoop.security.authentication", "kerberos");

UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab("hdfs@CLOUDERA", "/etc/hadoop/conf/hdfs.keytab");

FileSystem fs = FileSystem.get(conf);
FileStatus[] fsStatus = fs.listStatus(new Path("/"));
for (int i = 0; i < fsStatus.length; i++) {
    System.out.println(fsStatus[i].getPath().toString());
}

It fails with the following error:

 

java.io.IOException: Login failure for hdfs@CLOUDERA from keytab /etc/hadoop/conf/hdfs.keytab: javax.security.auth.login.LoginException: Unable to obtain password from user

 

The question is: how to I correctly handle the keytab? Do i have to copy it to my local machine? Do I have to install a Kerberos Client on Windows?

 

Thanks in advance and best regards!