设为首页 收藏本站
查看: 943|回复: 0

[经验分享] puppet三种认证注册方式详解及常见报错分析

[复制链接]

尚未签到

发表于 2018-8-1 13:44:06 | 显示全部楼层 |阅读模式
  本文主要介绍puppet的三种认证方式:自动注册、手动注册和预签名注册;master和agent的认证关系,是随着认证的复杂程度提升,安全性也会随之提高,下面就是每一种方式的示例解读。
  一 手动注册
  手动注册是由Agent端先发起证书申请请求,然后由Puppetserver端确认证书方可注册成功,这种注册方式安全系数中等,逐一注册(puppet cert --sign certnmame)在节点数量较大的情况下是比较麻烦的,效率也低,批量注册(puppet cert --sign --all)效率很高,一次性便可注册所有的Agent的请求,但是这种方式安全系数较低,因为错误的请求也会被注册上。
  1、节点申请认证
  [root@agent1 ~]# puppet agent --test
  info: Creating a new SSL key for agent1_cert.puppet.com
  info: Caching certificate for ca
  info: Creating a new SSL certificate request for agent1_cert.puppet.com
  info: Certificate Request fingerprint (md5): 69:D2:86:25:7F:00:RT:55:61:P9:02:34:9E:9B:AF:F9
  Exiting; no certificate found and waitforcert is disabled
  2、服务器端确定认证
  [root@master ~]# puppet cert --list --all                                         #查看认证情况
  "agent1_cert.puppet.com"  (69:D2:86:E4:7F:00:E0:55:61:19:02:34:9E:9B:AF:F9) #未认证
  + "master.puppet.com" (C0:E3:6B:76:36:EC:92:93:4D:BF:F0:8F:77:00:91:C8)
  [root@master ~]# puppet cert --sign agent1_cert.puppet.com     #注册agent1
  notice: Signed certificate request for agent1_cert.puppet.com #将请求的证书正式注册
  notice: Removing file Puppet::SSL::CertificateRequest agent1_cert.puppet.com at '/var/lib/puppet/ssl/ca/requests/agent1_cert.puppet.com.pem' #删除请求
  [root@master ~]# puppet cert --list --all                                 #再次查看认证情况
  + "agent1_cert.puppet.com"  (3E:46:4E:75:34:9A:5A:62:A6:3C:AE:BD:49:EE:C0:F5)
  + "master.puppet.com" (C0:E3:6B:76:36:EC:92:93:4D:BF:F0:8F:77:00:91:C8)
  [root@master ~]# tree /var/lib/puppet/ssl/                         #另外一种查看认证的方式
  /var/lib/puppet/ssl/
  ├── ca
  │   ├── ca_crl.pem
  │   ├── ca_crt.pem
  │   ├── ca_key.pem
  │   ├── ca_pub.pem
  │   ├── inventory.txt
  │   ├── private
  │   │   └── ca.pass
  │   ├── requests
  │   ├── serial
  │   └── signed
  │       ├── agent1_cert.puppet.com.pem  #已经注册成功
  │       └── master.puppet.com.pem
  ├── certificate_requests
  ├── certs
  │   ├── ca.pem
  │   └── master.puppet.com.pem
  ├── crl.pem
  ├── private
  ├── private_keys
  │   └── master.puppet.com.pem
  └── public_keys
  └── master.puppet.com.pem
  3、test模块测试
  [root@agent1 ~]# puppet agent --test  #测试节点agent1
  info: Caching catalog for agent1_cert.puppet.com
  info: Applying configuration version '1385309582'
  notice: /Stage[main]/test/File[/etc/test]/content:
  --- /etc/test    2016-12-13 07:18:52.000000000 +0800
  +++ /tmp/puppet-file20161213-4571-1vqc18j-0    2016-12-13 02:51:47.000000000 +0800
  @@ -0,0 +1,3 @@
  +--                       --
  +--------puppet test---------
  +--                       --
  info: FileBucket adding {md5}d41d8cd98f00b204e9800998ecf8427e
  info: /Stage[main]/test/File[/etc/test]: Filebucketed /etc/test to puppet with sum d41d8cd98f00b204e9800998ecf8427e
  notice: /Stage[main]/test/File[/etc/test]/content: content changed '{md5}d41d8cd98f00b204e9800998ecf8427e' to '{md5}87ea3a1af8650395038472457cc7f2b1'
  notice: Finished catalog run in 0.40 seconds
  二 自动注册
  
  这种注册方式简单来讲是通过master端的ACL列表进行控制的,安全系统较低,也就是说符合预先定义的ACL列表中的所有节点请求不需要确认都会被自动注册上,也就是说你只需要知道ACL列表要求,其次能和Master端通信便可轻易注册成功。当然,它的最大优点就是效率非常高。
  1、清除Master端已经注册的agent1的证书
  [root@master ~]# puppet cert --clean agent1_cert.puppet.com
  notice: Revoked certificate with serial 3
  notice: Removing file Puppet::SSL::Certificate agent1_cert.puppet.com at '/var/lib/puppet/ssl/ca/signed/agent1_cert.puppet.com.pem'
  notice: Removing file Puppet::SSL::Certificate agent1_cert.puppet.com at '/var/lib/puppet/ssl/certs/agent1_cert.puppet.com.pem'
  [root@master ~]# puppet cert --list  --all             #agent1证书已经删除
  + "agent2_cert.puppet.com"
  + "agent3_cert.puppet.com"
  + "master.puppet.com"
  + "master_cert.puppet.com" )
  2、在agent1端删除注册过的证书
  [root@agent1 ~]# rm -rf /var/lib/puppet/ssl/*
  3、在master端编写ACL列表
  [root@master ~]# vim /etc/puppet/autosign.conf
  *.puppet.com
  [root@master ~]# /etc/init.d/master restart
  Stopping master:                                     [  OK  ]
  Starting master:                                     [  OK  ]
  [root@master ~]# puppet cert --list  --all
  4、自动注册
  [root@agent1 ~]# puppet agent --test #申请证书
  info: Creating a new SSL key for agent1_cert.puppet.com
  info: Caching certificate for ca
  info: Creating a new SSL certificate request for agent1_cert.puppet.com
  info: Certificate Request fingerprint (md5): ED:C9:C7:DF:F1:0E:53:1C:D3:73:5D:B7:D3:94:1F:60
  info: Caching certificate for agent1_cert.puppet.com
  info: Caching certificate_revocation_list for ca
  info: Caching catalog for agent1_cert.puppet.com
  info: Applying configuration version '1394359075'
  notice: Finished catalog run in 1.39 seconds
  [root@agent1 ~]# cat /etc/test
  --                       --
  --------puppet test---------
  --                       --
  5、服务器端查看
  [root@master ~]# puppet cert --list  --all      #查看agent已经自动注册成功
  + "agent1_cert.puppet.com"
  + "agent2_cert.puppet.com"
  + "agent3_cert.puppet.com"
  + "master.puppet.com"
  + "master_cert.puppet.com"
  三 预签名认证
  预签名注册是在agent端未提出申请的情况下,预先在master端生成agent端的证书,然后复制到节点对应的目录下即可注册成功,这种方式安全系数最高,但是操作麻烦,需要提前预知所有节点服务器的certname名称,其次需要将生成的证书逐步copy到所有节点上去。不过,如果你的系统中安装了kickstart或者cobbler这样的自动化工具,倒是可以将证书部分转换成脚本集成到统一自动化部署中 注:生产环境中建议此方式进行注册,既安全又可靠!
  1、清除master端已经注册的agent1的证书
  [root@master ~]# puppet cert --clean agent1_cert.puppet.com
  notice: Revoked certificate with serial 3
  notice: Removing file Puppet::SSL::Certificate agent1_cert.puppet.com at '/var/lib/puppet/ssl/ca/signed/agent1_cert.puppet.com.pem'
  notice: Removing file Puppet::SSL::Certificate agent1_cert.puppet.com at '/var/lib/puppet/ssl/certs/agent1_cert.puppet.com.pem'
  2、在agent1端删除注册的所有信息,包括证书
  [root@agent1 ~]# rm -rf /var/lib/puppet/*
  3、删除自动注册ACL列表
  [root@master ~]# mv /etc/puppet/autosign.conf{,.bak}
  4、puppetserver端预先生成agent1证书
  [root@master ~]# puppetca --generate agent1_cert.puppet.com
  notice: agent1_cert.puppet.com has a waiting certificate request
  notice: Signed certificate request for agent1_cert.puppet.com
  notice: Removing file Puppet::SSL::CertificateRequest agent1_cert.puppet.com at '/var/lib/puppet/ssl/ca/requests/agent1_cert.puppet.com.pem'
  notice: Removing file Puppet::SSL::CertificateRequest agent1_cert.puppet.com at '/var/lib/puppet/ssl/certificate_requests/agent1_cert.puppet.com.pem'
  5、节点生成目录结构
  [root@agent1 ~]# puppet agent --test --server=abc.com     #随便指定server端,生成目录结构
  info: Creating a new SSL key for agent1_cert.puppet.com
  err: Could not request certificate: getaddrinfo: Temporary failure in name resolution
  Exiting; failed to retrieve certificate and waitforcert is disabled
  [root@agent1 ~]# tree /var/lib/puppet/ssl/
  /var/lib/puppet/ssl/
  |-- certificate_requests
  |-- certs
  |-- private
  |-- private_keys
  |   `-- agent1_cert.puppet.com.pem
  `-- public_keys
  `-- agent1_cert.puppet.com.pem
  6、master端copy证书到agent1上
  [root@master ~]# scp /var/lib/puppet/ssl/private_keys/agent1_cert.puppet.com.pem  agent1.puppet.com:/var/lib/puppet/ssl/private_keys/
  agent1_cert.puppet.com.pem                                                         100% 3243     3.2KB/s   00:00
  [root@master ~]# scp /var/lib/puppet/ssl/certs/agent1_cert.puppet.com.pem  agent1.puppet.com:/var/lib/puppet/ssl/certs/
  agent1_cert.puppet.com.pem                                                         100% 1944     1.9KB/s   00:00
  [root@master ~]# scp /var/lib/puppet/ssl/certs/ca.pem  agent1.puppet.com:/var/lib/puppet/ssl/certs/
  ca.pem                                                                                 100% 1915     1.9KB/s   00:00
  7、agent1测试
  [root@agent1 ~]# >/etc/test
  [root@agent1 ~]# puppet agent --test
  info: Caching certificate_revocation_list for ca
  info: Caching catalog for agent1_cert.puppet.com
  info: Applying configuration version '1394359075'
  notice: /Stage[main]/test/File[/etc/test]/content:
  --- /etc/test    2016-12-13 18:10:10.000000000 +0800
  +++ /tmp/puppet-file20161213-4071-1gypudk-0    2016-12-13 18:10:17.000000000 +0800
  @@ -0,0 +1,3 @@
  +--                       --
  +--------puppet test---------
  +--                       --
  info: FileBucket adding {md5}d41d8cd98f00b204e9800998ecf8427e
  info: /Stage[main]/test/File[/etc/test]: Filebucketed /etc/test to puppet with sum d41d8cd98f00b204e9800998ecf8427e
  notice: /Stage[main]/test/File[/etc/test]/content: content changed '{md5}d41d8cd98f00b204e9800998ecf8427e' to '{md5}87ea3a1af8650395038472457cc7f2b1'
  info: Creating state file /var/lib/puppet/state/state.yaml
  notice: Finished catalog run in 0.41 seconds
  [root@agent1 ~]# cat /etc/test
  --                       --
  --------puppet test---------
  --                       --
  四 常见错误情况及解决办法
  1.  连接master的时候出现如下报错:
  dnsdomainname: Unknown host
  解决办法:检查机器主机名的设置,以及是否添加进hosts。
  2.   连接master的时候出现如下报错:
  err: Could not request certificate: getaddrinfo: Name or service not known
  解决办法:服务器端没有配置hosts域名绑定,在hosts中添加。
  3.  连接master的时候出现如下报错:
  warning: peer certificate won't be verified in this SSL session
  解决办法:服务端还没有返回签发证书,使用puppet cert --list查看
  4.  连接master的时候出现如下报错:
  err: Could not retrieve catalog from remote server: certificate verify failed
  解决办法:客户端和服务器端时间不同步,用ntpdate命令同步时间
  5. Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at ';'; expected '}' at /etc/puppet/manifests/site.pp:3 on node server-02
  解决办法:修改site.pp ,脚本中出现语法错误
  6. Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve information from environment production source(s) puppet://server-01/plugins
  解决办法:分别在客户端和服务器修改puppet.conf文件,添加“pluginsync=false",并分别重启服务
  7. 执行 puppet agent --test --server=server-01 提示:
  Notice: Run of Puppet configuration client already in progress; skipping (/var/lib/puppet/state/agent_catalog_run.lock exists)
  解决办法:出现此提示为 配置文件不正确,或者服务器端的.pp 文件的语法错误,请去修改.pp 文件
  8. Error: Could not request certificate: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed: [self signed certificate in certificate chain for /CN=Puppet CA: server-01]
  解决办法:删除客户端证书、删除puppetmaster上的客户端证书、客户端重新生成证书请求、puppetmaster重新签名
  1)、rm /var/lib/puppet/ssl/ 证书
  2)、puppet cert clean 客户端主机名
  3)、puppet agent --test --server puppetmaster
  4)、puppet cert --sign 客户端主机名
  9.   certificate verify failed: [CRL is not yet valid for /CN=server.minunix.com]
  解决方法:master和agent 把时间同步下就OK 了
  ntpdate -u 210.72.145.44
  10. Error: Host server01 failed: Error 403 on SERVER: Forbidden request: server01(172.16.8.250) access to /run/server01 [save] authenticated at :119
  在puppet 服务端尝试推送数据来更新客户端的时候提示这样的问题;
  解决办法:
  # vim /etc/puppet/auth.conf
  path /
  auth any
  allow *

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-544868-1-1.html 上篇帖子: centos 7下安装配置puppet-12555547 下篇帖子: puppet完整模块实例分步解读
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表