others linux服务器运维 django3 监控 k8s golang 数据库 大数据 前端 devops 理论基础 java oracle 运维日志

centos7 kerberos 安装

访问量:1455 创建时间:2020-06-04
机器信息 kdc角色
192.168.31.132 kdc server & client
192.168.31.133 client
192.168.31.134 client
192.168.31.135 client
192.168.31.136 client

kdc server安装

#在kdc server机器执行
[root@node1 ~]# yum -y install krb5-server krb5-libs krb5-auth-dialog krb5-workstation
[root@node1 ~]# cat  /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]
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true
 rdns = false
 pkinit_anchors = FILE:/etc/pki/tls/certs/ca-bundle.crt
 default_realm = work.com
 default_ccache_name = KEYRING:persistent:%{uid}

[realms]
  work.com = {
  kdc = node1.work.com
  admin_server = node1.work.com
 }

[domain_realm]
# .example.com = EXAMPLE.COM
# example.com = EXAMPLE.COM

# 配置管理员账号
[root@node1 ~]# vim /var/kerberos/krb5kdc/kadm5.acl 

*/admin@work.com        *

[root@node1 ~]# vi /var/kerberos/krb5kdc/kdc.conf 

[kdcdefaults]
 kdc_ports = 88
 kdc_tcp_ports = 88

[realms]
 work.com = {
  #master_key_type = aes256-cts
  max_renewable_life= 7d 0h 0m 0s
  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 camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
 }

初始化Kerberos数据库

[root@node1 ~]# kdb5_util create -r work.com -s
Loading random data
Initializing database '/var/kerberos/krb5kdc/principal' for realm 'work.com',
master key name 'K/M@work.com'
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter KDC database master key: 
Re-enter KDC database master key to verify: 
#保存好密码

创建能远程登录的管理员账户

[root@node1 ~]# kadmin.local
Authenticating as principal root/admin@work.com with password.
kadmin.local:  addprinc admin/admin@work.com
WARNING: no policy specified for admin/admin@work.com; defaulting to no policy
Enter password for principal "admin/admin@work.com": 
Re-enter password for principal "admin/admin@work.com": 
Principal "admin/admin@work.com" created.
kadmin.local:  
#保存好密码

启动服务

[root@node1 ~]# systemctl enable krb5kdc
Created symlink from /etc/systemd/system/multi-user.target.wants/krb5kdc.service to /usr/lib/systemd/system/krb5kdc.service.
[root@node1 ~]# systemctl enable kadmin
Created symlink from /etc/systemd/system/multi-user.target.wants/kadmin.service to /usr/lib/systemd/system/kadmin.service.
[root@node1 ~]# systemctl start krb5kdc
[root@node1 ~]# systemctl start kadmin

用admin账号测试一下

[root@node1 ~]# kinit admin/admin@work.com
Password for admin/admin@work.com: 
[root@node1 ~]# klist 
Ticket cache: KEYRING:persistent:0:0
Default principal: admin/admin@work.com

Valid starting       Expires              Service principal
06/04/2020 20:54:25  06/05/2020 20:54:25  krbtgt/work.com@work.com
    renew until 06/11/2020 20:54:25
[root@node1 ~]# kdestroy 
[root@node1 ~]# klist 
klist: Credentials cache keyring 'persistent:0:0' not found

客户端安装

另外机器执行

#所有client节点都要执行

[root@node2 ~]# yum -y install krb5-libs krb5-workstation
#同步配置文件,从kdcserver节点同步到client节点所有机器
[root@node1 ~]# scp /etc/krb5.conf 192.168.31.133:/etc/

#在其他机器测试一下登录admin账户
[root@node2 ~]# kinit admin/admin
Password for admin/admin@work.com: 
You have new mail in /var/spool/mail/root
[root@node2 ~]# klist 
Ticket cache: KEYRING:persistent:0:0
Default principal: admin/admin@work.com

Valid starting       Expires              Service principal
06/04/2020 21:03:42  06/05/2020 21:03:42  krbtgt/work.com@work.com
    renew until 06/11/2020 21:03:42
登陆评论: 使用GITHUB登陆