<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: HDFS is not accessible from an user after kerberos implementation in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/HDFS-is-not-accessible-from-an-user-after-kerberos/m-p/268878#M206457</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/49879"&gt;@pritam_konar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In reality a user shouldn't be able to &lt;STRONG&gt;execute&lt;/STRONG&gt; or &lt;STRONG&gt;kinit&lt;/STRONG&gt; with the &lt;STRONG&gt;hdfs keytab&lt;/STRONG&gt; but have a keytab created for the specific user and when need be deleted when the user is disabled on the cluster typically this user setup happens on the edge node where the hadoop client software are installed and is the recommended setup for giving users access to the cluster.&lt;/P&gt;&lt;P&gt;Below is a demo of the user konar when he attempts to access services in a kerberized cluster&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;# su - konar&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ id&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;uid=1024(konar) gid=1024(konar) groups=1024(konar)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Now try to list the directories in HDFS&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ hdfs dfs -ls /&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Error&amp;nbsp;&lt;BR /&gt;19/08/24 23:59:25 WARN ipc.Client: Exception encountered while connecting to the server : javax.security.sasl.SaslException: GSS initiate failed [&lt;STRONG&gt;Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt&lt;/STRONG&gt;)]&lt;BR /&gt;ls: Failed on local exception: java.io.IOException: javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]; Host Details : local host is: "simba.kenya.ke/192.168.0.87"; destination host is: "simba.kenya.ke":8020;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the desired output when the user konar attempts to use the hdfs headless keytab,&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ kinit -kt /etc/security/keytabs/hdfs.headless.keytab hdfs-jair@KENYA.KE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;kinit: Permission denied while getting initial credentials&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;To enable a user to access the cluster, on the Kerberos server as the root (Keberos admin)&amp;nbsp; do the following steps,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Assumption&lt;/STRONG&gt;&amp;nbsp; Realm is &lt;STRONG&gt;KENYA.KE&amp;nbsp;&lt;/STRONG&gt; and&lt;STRONG&gt; KDC&amp;nbsp;&lt;/STRONG&gt; host is &lt;STRONG&gt;simba&lt;/STRONG&gt; and you have root access on the KDC.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Create the admin principle for user konar&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[root@simba ~]# kadmin.local&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Authenticating as principal root/admin@KENYA.KE with password.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;kadmin.local: addprinc konar@KENYA.KE&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;WARNING: no policy specified for konar@KENYA.KE; defaulting to no policy&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Enter password for principal "konar@KENYA.KE":&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Re-enter password for principal "konar@KENYA.KE":&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Principal "konar@KENYA.KE" created.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;kadmin.local: q&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Validate the principal was created using the subcommand listprincs [List principals] and limiting the output by restricting to&amp;nbsp; konar classic Unix stuff&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[root@simba ~]# kadmin.local&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Authenticating as principal root/admin@KENYA.KE with password.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;kadmin.local: listprincs *konar&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;konar@KENYA.KE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Type q [&lt;STRONG&gt;quit&lt;/STRONG&gt;] to exit the kadmin utility&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Generate the keytab &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Generate keytab for user &lt;STRONG&gt;konar&lt;/STRONG&gt; using the &lt;STRONG&gt;ktutil&lt;/STRONG&gt;, it's good to change to &lt;STRONG&gt;/tmp&lt;/STRONG&gt; or whatever you choose so you know the location of the generated keytab your encryption Algorithm could be different but this should work&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[root@simba tmp]# ktutil&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;ktutil: addent -password -p konar@KENYA.KE -k 1 -e RC4-HMAC&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Password for konar@KENYA.KE:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;ktutil: wkt konar.keytab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;ktutil: q&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Validate the keytab creation&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Check the keytab was generated in the current directory, notice the file permissions!!&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[root@simba tmp]# ls -lrt&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;-rw------- 1 root root 58 Aug 25 18:22 konar.keytab&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As root copy the generate keytab to the home directory of user konar typically on the edge node&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[root@simba tmp]# cp konar.keytab /home/konar/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change to konar's home dir and vaildate the copy was successful&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;[root@simba tmp]# cd /home/konar/&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;[root@simba konar]# ll&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;total 4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;-rw------- 1 root root 58 Aug 25 18:28 konar.keytab&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Change file ownership&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Change the file permission on the konar.keytab so that user konar has the appropriate permissions.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[root@simba konar]# chown konar:konar konar.keytab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;[root@simba konar]# ll&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;total 4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;-rw------- 1 konar konar 58 Aug 25 18:28 konar.keytab&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Switch to user konar and validate that the user has can't&amp;nbsp; still access to hdfs&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;$ hdfs dfs -ls /&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ hdfs dfs -ls /&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output&lt;/STRONG&gt;&lt;BR /&gt;19/08/25 18:36:44 WARN ipc.Client: Exception encountered while connecting to the server : javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException:&lt;STRONG&gt; No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]&lt;/STRONG&gt;&lt;BR /&gt;ls: Failed on local exception: java.io.IOException: javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)]; Host Details : local host is: "simba.kenya.ke/192.168.0.87"; destination host is: "simba.kenya.ke":8020;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The kerberos klist also confirms that&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ klist&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;klist: No credentials cache found (filename: /tmp/krb5cc_1024)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As user Konar now try to &lt;STRONG&gt;kinit&lt;/STRONG&gt; with the correct principal, the first step is to identify the correct principal&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ klist -kt konar.keytab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Keytab name: FILE:konar.keytab&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;KVNO Timestamp Principal&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;---- ------------------- ------------------------------------------------------&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;1 08/25/2019 18:22:34 konar@KENYA.KE&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The above shows the konar user keytab is valid with the principal in the output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now user konar can grab a valid ticket ûsing the below snippet concatenating the keytab + principal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ kinit -kt konar.keytab konar@KENYA.KE&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The above should throw any error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now validate the user has a valid ticket&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ klist&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Ticket cache: FILE:/tmp/krb5cc_1024&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Default principal: konar@KENYA.KE&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;Valid starting Expires Service principal&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;08/25/2019 18:53:40 08/26/2019 18:53:40 krbtgt/KENYA.KE@KENYA.KE&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Bravo you have a valid ticket and hence access to the cluster let's validate that the below&amp;nbsp; HDFS list&amp;nbsp; directory should succeed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;[konar@simba ~]$ hdfs dfs -ls /&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;Found 10 items&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxrwxrwx - yarn hadoop 0 2018-12-17 21:53 /app-logs&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxr-xr-x - hdfs hdfs 0 2018-09-24 00:22 /apps&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxr-xr-x - yarn hadoop 0 2018-09-24 00:12 /ats&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxr-xr-x - hdfs hdfs 0 2018-09-24 00:12 /hdp&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxr-xr-x - mapred hdfs 0 2018-09-24 00:12 /mapred&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxrwxrwx - mapred hadoop 0 2018-09-24 00:12 /mr-history&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxr-xr-x - hdfs hdfs 0 2018-12-17 19:16 /ranger&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxrwxrwx - spark hadoop 0 2019-08-25 18:59 /spark2-history&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxrwxrwx - hdfs hdfs 0 2018-10-11 11:16 /tmp&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;drwxr-xr-x - hdfs hdfs 0 2018-09-24 00:23 /user&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;User konar can now list and execute jobs on the cluster !!!! as reiterated the &lt;STRONG&gt;konar&lt;/STRONG&gt; user in a recommended architecture should be on the edge node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 25 Aug 2019 17:28:06 GMT</pubDate>
    <dc:creator>Shelton</dc:creator>
    <dc:date>2019-08-25T17:28:06Z</dc:date>
  </channel>
</rss>

