Kerberos 命令使用
程序员文章站
2024-02-28 11:49:28
...
指南
登录 kinit admin/[email protected]
[[email protected] ~]# kinit admin/[email protected]
Password for admin/[email protected]: 123456
查询登录状态 klist
[[email protected] ~]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: admin/[email protected]
Valid starting Expires Service principal
2018-07-12T00:54:55 2018-07-13T00:54:55 krbtgt/[email protected]
退出 kdestroy
[[email protected] ~]# kdestroy
[[email protected] ~]# klist
klist: No credentials cache found (filename: /tmp/krb5cc_0)
指使指南(维护)
登录管理KDC
服务器
登录后台 kadmin.local
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local:
查看用户列表 listprincs
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: listprincs
K/[email protected]
activity_analyzer/[email protected]
activity_explorer/[email protected]
admin/[email protected]
...
修改帐号密码(可修改忘记密码)
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: change_password admin/[email protected]
Enter password for principal "admin/[email protected]": 123456
Re-enter password for principal "admin/[email protected]": 123456
Password for "admin/[email protected]" changed.
创建用户
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: add_principal test1
WARNING: no policy specified for [email protected]; defaulting to no policy
Enter password for principal "[email protected]": 123456
Re-enter password for principal "[email protected]": 123456
Principal "[email protected]" created.
删除用户
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: delete_principal test1
Are you sure you want to delete the principal "[email protected]"? (yes/no): yes
Principal "[email protected]" deleted.
Make sure that you have removed this principal from all ACLs before reusing.
只导出用户keytab
文件(并且不要修改密码)
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: xst -k admin.keytab -norandkey admin/[email protected]
Entry for principal admin/[email protected] with kvno 6, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type aes128-cts-hmac-sha1-96 added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type des3-cbc-sha1 added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type arcfour-hmac added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type camellia256-cts-cmac added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type camellia128-cts-cmac added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type des-hmac-sha1 added to keytab WRFILE:admin.keytab.
Entry for principal admin/[email protected] with kvno 6, encryption type des-cbc-md5 added to keytab WRFILE:admin.keytab.
kadmin.local: exit
PS:有些教程说是ktadd
,其实它们是一样的效果,在命令使用帮助中我们可以查询到哪些命令是一样的。
[[email protected] ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: ? #是查看帮助命令
Available kadmin.local requests:
add_principal, addprinc, ank
Add principal
delete_principal, delprinc
Delete principal
modify_principal, modprinc
Modify principal
rename_principal, renprinc
Rename principal
change_password, cpw Change password
get_principal, getprinc Get principal
list_principals, listprincs, get_principals, getprincs
List principals
add_policy, addpol Add policy
modify_policy, modpol Modify policy
delete_policy, delpol Delete policy
get_policy, getpol Get policy
list_policies, listpols, get_policies, getpols
List policies
get_privs, getprivs Get privileges
ktadd, xst Add entry(s) to a keytab
ktremove, ktrem Remove entry(s) from a keytab
lock Lock database exclusively (use with extreme caution!)
unlock Release exclusive database lock
purgekeys Purge previously retained old keys from a principal
get_strings, getstrs Show string attributes on a principal
set_string, setstr Set a string attribute on a principal
del_string, delstr Delete a string attribute on a principal
list_requests, lr, ? List available requests.
quit, exit, q Exit program.
用逗号分隔的命令就是相等的,例如
add_principal, addprinc, ank
delete_principal, delprinc
ktadd, xst
...等等
使用Keytab
验证是否可以登录(无错误输出即可)
kinit -kt /etc/security/keytabs/admin.keytab admin/[email protected]
查看keytab
文件中的帐号列表
[[email protected] ~]# klist -ket hbase.headless.keytab
Keytab name: FILE:hbase.headless.keytab
KVNO Timestamp Principal
---- ------------------- ------------------------------------------------------
7 2018-07-30T10:19:16 [email protected] (des-cbc-md5)
7 2018-07-30T10:19:16 [email protected] (aes128-cts-hmac-sha1-96)
7 2018-07-30T10:19:16 [email protected] (aes256-cts-hmac-sha1-96)
7 2018-07-30T10:19:16 [email protected] (des3-cbc-sha1)
7 2018-07-30T10:19:16 [email protected] (arcfour-hmac)
下一篇: fetch的二次封装