`

keytab file in kerberos

 
阅读更多

How to create a keytab file for a Kerberos user logging into Active Directory.  What's a keytab file?  It's basically a file that contains a table of user accounts, with an encrypted hash of the user's password.  Why have a keytab file?  Well, when you want a server process to automatically logon to Active Directory on startup, you have two options:  type the password (in clear text) into a config file somewhere, or store an encrypted hash of the password in a keytab file.  Which is safer?  Well, you can decide.  In any case, you'd better do a good job of protecting the file (be it a config file or a keytab).

Anyway, the accepted way to store a hashed password in Kerberos is to use a keytab file.  Now the file can be created using a number of utilities.  On a Windows machine, you can use ktpass.exe.  On Ubuntu Linux, you can use ktutil.

<iframe id="aswift_1" style="left: 0px; position: absolute; top: 0px;" name="aswift_1" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="468" height="60"></iframe> 

Before I demonstrate how to create the keytab, a word about encryption.  There are a number of encryption types used for hashing a password.  These include DES-CBC-CRC, DES-CBC-MD5, RC4-HMAC and a few others.  Active Directory uses RC4-HMAC by default.  Back in Windows 2000, you could also use the DES types without any trouble, but since Windows 2003, only RC4-HMAC is supported, unless you make a registry change (to all of your domain controllers).  If you need to use DES for some reason, then refer to the Technet article at the bottom of the page.

Before attempting to create a keytab file, you'll need to know the user's kerberos principal name, in the form of username@MYDOMAIN.COM, and the user's password.

Creating a KeyTab on Windows (tested on Windows Server 2008 R2)
Open a command prompt and type the following command:

ktpass /princ username@MYDOMAIN.COM /pass password /ptype KRB5_NT_PRINCIPAL /out username.keytab
 

Creating a KeyTab on Ubuntu Linux (tested on Ubuntu 10.10 - Maverick Meerkat)
Open a terminal window and type the following commands:

ktutil
addent -password -p username@MYDOMAIN.COM -k 1 -e RC4-HMAC
- enter password for username -
wkt username.keytab
q

Testing the Keytab File
Now in order to test the keytab, you'll need a copy of kinit.  You can use the version that's on Ubuntu, or if on Windows, you can install the latest Java runtime from Sun (JRE).  In either case, you'll need to setup your /etc/krb5.conf file (on Linux) or c:\windows\krb5.ini (on Windows).  Either file should look something like this:

[libdefaults]
default_realm = MYDOMAIN.COM
krb4_config = /etc/krb.conf
krb4_realms = /etc/krb.realms
kdc_timesync = 1
ccache_type = 4
forwardable = true
proxiable = true

[realms]
MYDOMAIN.COM = {
kdc = mydomain.com:88
admin_server = mydomain.com
default_domain = mydomain.com
}

[domain_realm]
.mydomain.com = MYDOMAIN.COM
mydomain.com = MYDOMAIN.COM

[login]
krb4_convert = true
krb4_get_tickets = false

Once you've got your Kerberos file setup, you can use kinit to test the keytab.  First, try to logon with your user account without using the keytab:

kinit username@MYDOMAIN.COM
- enter the password - 

If that doesn't work, your krb5 file is wrong.  If it does work, now try the keytab file:

kinit username@MYDOMAIN.COM -k -t username.keytab

Now you should successfully authenticate without being prompted for a password.  Success!

More Information
If you need to use any other encryption Type than RC4-HMAC, then you'll need to tweak your AD domain controllers.  Please refer to the following TechNet article.

分享到:
评论

相关推荐

    flink写入带kerberos认证的kudu connector

    properties.setProperty("kudu.kerberos.keytab", "/path/to/your/keytab/file"); // 使用Table API StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); TableEnvironment ...

    kafka 配置kerberos安全认证

    scp /var/kerberos/krb5kdc/zookeeper.keytab hadoop03:/opt/beh/keytab/ chown hadoop:hadoop zookeeper.keytab ``` #### 五、配置 Zookeeper 的 Kerberos 认证 接下来,我们需要为 Zookeeper 配置 Kerberos 认证...

    springboot工程集成华为平台带kerberos认证kafka

    确保替换上述配置中的`your.kafka.broker.url`为实际的Kafka集群地址,`path/to/your/kerberos/keytab/file.keytab`和`path/to/your/krb5.conf`分别为你的Kerberos Keytab文件和Kerberos配置文件的路径,`your_...

    kerberos认证hive连接代码

    &lt;property name="keyTabFile" value="/path/to/keytab/file.keytab"/&gt; ``` 3. **Spring MVC集成**:在`JdbcListener.java`中,我们可以实现Spring的`ApplicationListener`接口,监听`ContextRefreshedEvent`,...

    python3.6.5基于kerberos认证的hive和hdfs连接调用方式

    接着,使用`kinit`命令生成`ccache_file`或`keytab_file`,这两个文件用于存储Kerberos票据和密钥。`keytab_file`是固定的密钥表文件,`ccache_file`是缓存的凭据文件,它们都可以用来进行身份验证。 现在,我们...

    kerberos安全认证

    在Hadoop配置中设置`mapreduce.job.kerberos.principal`和`mapreduce.job.kerberos.keytab.file`即可。 - **Kafka**: Kafka支持Kerberos认证,以增强消息传递的安全性。在Kafka配置中,设置`security.inter.broker....

    大数据平台-kerberos安装部署文档.pdf

    * kdc.conf文件:kdc_ports、realms、kadmind_port、max_life、max_renewable_life、database_name、admin_keytab、acl_file、key_stash_file等参数的配置 四、Kerberos安装部署注意事项 * Kerberos安装需要在...

    大数据安全-kerberos技术-hbase安装包,hbase版本:hbase-2.2.6-bin.tar.gz

    2. **配置HBase**:修改HBase的配置文件(如`hbase-site.xml`),设置`hbase.security.authentication`为`kerberos`,并提供Kerberos相关属性,如`hbase.kerberos.keytab.file`和`hbase.kerberos.principal`。...

    hadoop security

    例如,日志中会显示类似“Login successful for user hadoop/test84.hadoop@DIANPING.COM using keytab file /etc/hadoop.keytab”的信息,表明Kerberos登录成功。 **总结** 在部署Hadoop Security时,通过Hive ...

    greenplum-db-6.2.1-rhel7-x86_64.rpm

    The PXF_USER_IMPERSONATION, PXF_PRINCIPAL, and PXF_KEYTAB settings in the pxf-env.sh file. You can use the pxf-site.xml file to configure Kerberos and impersonation settings for your new Hadoop server...

    jdbc访问hive的jar包

    props.setProperty("keytab", "/path/to/keytab/file.keytab"); Connection conn = DriverManager.getConnection(url, props); ``` 4. **执行SQL查询**:连接建立后,可以使用`Statement`或`PreparedStatement`...

    将samba加入到windows的ad域

    5. **配置系统账户**:使用`net ads keytab create -U administrator`命令生成Kerberos密钥表文件,然后在`/etc/krb5.keytab`中设置权限,以允许Samba使用它进行身份验证。 6. **测试连接**:最后,重启Samba服务...

    nfs-ganesha-adminguide.pdf

    - `NFS_KRB5_KEYTAB_FILE`:keytab文件路径。 **2.2.22 NFSv4 区块** 该区块用于配置NFS v4.1版本的具体参数。例如: ```plaintext NFSv4 { NFSV4_MINOR_VERSION = 1; } ``` - `NFSV4_MINOR_VERSION`:NFS v4.1...

    连接hive依赖的jar包_hive连接方式

    如果Hive服务器配置了Kerberos安全认证,还需要在DataGrip中配置Kerberos相关参数,如"principal"和"keytab"文件路径。此外,可能需要在本地环境中设置Kerberos环境变量,例如`KRB5_CONFIG`和`JAVA_OPTS`。 6. **...

    Tomcat中访问AD Server的配置方法

    keyTab="/path/to/keytab/file" storeKey=true isInitiator=true debug=true principal="HTTP/host.mydomain.com@MY.DOMAIN.COM"; ``` 这里的关键是配置 `principal` 字段,使其与在 Active Directory 中注册...

    hadoop 2.9.0 yarn-default.xml 属性集

    19. yarn.resourcemanager.webapp.spnego-keytab-file:此属性设置用于安全谈判协议(SPNEGO)的身份验证服务主体的密钥表文件路径。 20. yarn.resourcemanager.webapp.spnego-principal:此属性设置SPNEGO身份验证...

    winutils.exe.zip_hadoop2.7+

    2. **安全设置**:如果Hadoop集群启用了安全性,比如Kerberos,那么需要正确配置相关安全设置,包括principal和keytab文件。 3. **JDK兼容性**:确保使用的Java Development Kit (JDK)版本与Hadoop 2.7+兼容,因为...

    HBase配置

    对于安全环境,需要配置HBase的Kerberos认证,如`hbase.security.authentication`设为`kerberos`,并正确配置相关Keytab文件和principal。 总结来说,HBase的配置涉及多个层面,包括基础设置、性能优化、安全性...

    搭建hadoop集群的全部配置文件

    - **kerberos**相关文件:如果启用了Kerberos安全机制,会包含keytab文件和相关配置,用于实现身份验证。 5. **集群扩展性**:通过调整配置文件中的参数,可以灵活地增加或减少节点,以适应不同规模的集群需求。 ...

Global site tag (gtag.js) - Google Analytics