title: Kerberos kinit: Resource temporarily unavailable while getting initial credentials
body: <p>I am in the process of setting up Kerberos on a CentOS7 (more specific: the Hortonworks HDP 2.3 sandbox) running in a VirtualBox VM. My problem is that kinit seems to be unable to reach my KDC, the answer is <strong>"Resource temporarily unavailable while getting inital credentials"</strong> if I add an address in my <em>/etc/hosts</em> file and if I leave that file as is I get the message <strong>"could not contact any host for realm mycompany while getting initial credentials"</strong>.<br>
  The KDC is running (can find it with ps plus the service starts with an "okay" message), same for kadmin.  </p>
  
  <p>As a guide for setting up kerberos I followed these two guides:<br>
  <a href="https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-kerberos-server.html" rel="nofollow">CentOS guide</a><br>
  <a href="http://henning.kropponline.de/2014/10/05/kerberized-hadoop-cluster-sandbox-example/" rel="nofollow">Guide 2</a>  </p>
  
  <p>My config files:
  krb5.conf  </p>
  
  <pre><code>[logging]
    default = FILE:/var/log/krb5libs.log/krb5libs.log
    kdc = FILE:/var/log/krb5kdc.log
    admin_server = FILE:/var/log/kadmin.log
  
  [libdefaults]
    default_realm = MYCOMPANY.COM
    dns_lookup_realm = true
    dns_lookup_kdc = true
    ticket_lifetime = 24h
    renew_lifetime = 7d
    forwardable = true
  
  
  [realms]
    MYCOMPANY.COM = {
      kdc = kerberos.mycompany.com
      admin_server = kerberos.mycompany.com
    }
  
  [domain_realm]
    .mycompany.com = MYCOMPANY.COM
    mycompany.com = MYCOMPANY.COM
  </code></pre>
  
  <p>kdc.conf</p>
  
  <pre><code>[kdcdefaults]
    kdc_ports = 88
    kdc_tcp_ports = 88,750
  
  [realms]
    MYCOMPANY.COM = {
      #master_key_type = aes256-cts
      acl_file = /var/kerberos/krb5kdc/kadm5.acl
      dict_file = /usr/share/dict/words
      admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
      supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
    }
  </code></pre>
  
  <p>kadm5.acl</p>
  
  <pre><code>*/admin@MYCOMPANY.COM *
  </code></pre>
  
  <p>/etc/hosts</p>
  
  <pre><code>127.0.0.1       localhost.localdomain localhost
  192.168.96.140  sandbox.hortonworks.com sandbox ambari.hortonworks.com
  192.168.1.3     mycompany.com kerberos.mycompany.com
  </code></pre>
  
  <p>I get the "Resource..." error if I have any address in the third line of the hosts file, if that line is missing I get the "could not contact..." error.</p>
  
  <p>I could trace the kinit command with something along the lines of krb5_trace or something (unfortunately I can't find the link I got it from any more nor remember the exact command) to the address specified in the host file so kinit seems to contact the fitting address, its just that the KDC does not listen there.<br>
  Netstat shows that the KDC is listening on the ports specified in the kdc.conf</p>
  
  <p>Any help would be appreciated</p>