系统版本:CentOS Linux release 7.2.1511
首先,我们了解下kerberos是个什么东西?
Kerberos协议主要用于计算机网络的身份鉴别(Authentication), 其特点是用户只需输入一次身份验证信息就可以凭借此验证获得的票据(ticket-granting ticket)访问多个服务,即SSO(Single Sign On)。由于在每个Client和Service之间建立了共享密钥,使得该协议具有相当的安全性。Kerberos简易流程说明:
注:以下搭建环境基于centos7 1511 minimal版本,内网各个主机添加了dns内部解析及ntp时间同步。
1、kerberos服务端软件包安装
yum install krb5-server krb5-libs krb5-workstation -y
2、修改/etc/krb5.conf# Configuration snippets may be placed in this directory as well
#includedir /etc/krb5.conf.d/
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = TEST.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
clockskew = 600
[realms]
TEST.COM = {
kdc = bigdatademo
admin_server = bigdatademo
}
[domain_realm]
.test.com = TEST.COM
test.com = TEST.COM
3、修改/var/kerberos/krb5kdc/kdc.conf配置样例:
[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88
[realms]
TEST.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
max_life = 1d
max_renewable_life = 7d
supported_enctypes = aes256-cts:normal aes128-cts:normal arcfour-hmac:normal
default_principal_flags = +renewable, +forwardable
}
4、修改/var/kerberos/krb5kdc/kadm5.acl,设置database administrator的ACL权限
*/[email protected] *
代表名称匹配*/[email protected]都认为是admin,权限是*(所有)
6、开启kerberos
systemctl restart krb5kdc
systemctl restart kadmin
systemctl enable krb5kdc
systemctl enable kadmin
现在KDC已经在工作了,两个daemons将会在后台运行,可以查看他们的日志文件/var/log/krb5kdc.log、/var/log/kadmind.log
7、使用本地方式添加admin权限用户
# kadmin.local -q "addprinc oiteboy/admin"
Authenticating as principal root/[email protected] with password.
WARNING: no policy specified for oiteboy/[email protected]; defaulting to no policy
Enter password for principal "oiteboy/[email protected]":
Re-enter password for principal "oiteboy/[email protected]":
Principal "oiteboy/[email protected]" created.
8、检查kdc是否OK
kinit 获取票据到缓存中
# kinit oiteboy/admin
Password for oiteboy/[email protected]:
klist 查看缓存中的内容
# klist -e
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: oiteboy/[email protected]
Valid starting Expires Service principal
07/06/2018 10:11:58 07/07/2018 10:11:58 krbtgt/[email protected]
renew until 07/13/2018 10:11:58, Etype (skey, tkt): aes128-cts-hmac-sha1-96, aes128-cts-hmac-sha1-96
1、客户端安装
yum install krb5-workstation
2、复制Kerberos server的/etc/krb.conf到client的/etc/krb.conf
在kerberos server/client添加主机名映射到 /etc/hosts
3、authenticate the admin user with kerberos
# kinit oiteboy/admin
Password for oiteboy/[email protected]:
# kadmin
Authenticating as principal oiteboy/[email protected] with password.
Password for oiteboy/[email protected]:
kadmin: listprincs