使用kadmin.local命令登录
或者kadmin
认证 klinit admin/admin
查看命令列表:?
查看已经存在的凭据:
list_principals, listprincs, get_principals, getprincs
添加凭据:add_principal, addprinc, ank
#添加principal
addprinc -randkey hadoop/172.24.215.5
addprinc -randkey hadoop
脚本执行如下:
kadmin.local -q “addprinc -randkey hadoop/172.24.215.5”
kadmin.local -q “addprinc -randkey HTTP/172.24.215.5”
kadmin.local -q “addprinc -randkey zookeeper/172.24.215.5”
生成keytab文件
ktadd -k /home/chen/cwd.keytab test@HADOOP.COM
xst -norandkey -k /home/chen/cwd.keytab test@HADOOP.COM
#注意:在生成keytab文件时需要加参数”-norandkey”,否则会导致直接使用kinit test@HADOOP.COM初始化时会提示密码错误。
脚本执行
kadmin.local -q “xst -norandkey -k emr.keytab hadoop”
kadmin.local -q “xst -norandkey -k emr.keytab hadoop/172.24.215.5@BINGSHENG.TC-SIT”
kadmin.local -q “xst -norandkey -k emr.keytab HTTP/172.24.215.5@BINGSHENG.TC-SIT”
kadmin.local -q “xst -norandkey -k emr.keytab zookeeper/172.24.215.5@BINGSHENG.TC-SIT”
修改凭据密码:change_password, cpw
change_password admin/admin@EXAMPLE.COM
删除凭据:delete_principal, delprinck
delprinc hadoop/172.24.215.5@BINGSHENG.TC-SIT
根据keytab文件查询用户
klist -kt /etc/security/keytabs/hdfs.headless.keytab
切换票据
kinit -kt /etc/security/keytabs/hdfs.headless.keytab hdfs-hdv4@BIGDATA
查看当前认知用户:klist
删除当前的认证的缓存
kdestroy
[root@cdh-node-2 /]# kdestroy
[root@cdh-node-2 /]# klist
klist: No credentials cache found (filename: /tmp/krb5cc_0)
查看keytab文件中的帐号列表
klist -ket /etc/security/keytab/presto.keytab
备份kerberos数据
/usr/sbin/kdb5_util dump /cfs/backup.dump
还原kerberos数据
/usr/sbin/kdb5_util load /cfs/backup.dump