Shell online environment puppet certificate exception re-Authentication script

Source: Internet
Author: User
During work, the puppet server/client certificate authentication exception is often encountered, and the certificate needs to be regenerated. Common operations are to delete the old certificates related to the server/client certificate, and then generate a new certificate. In this case, a shell script is compiled, which only needs to be periodically run on the Client side. Because the script involves the plaintext password, in order to improve security, you can consider this script encryption (see: http://lxsym.blog.51cto.com/1364623/768286&nb often encounter puppet server/client certificate authentication exception, you need to regenerate the certificate. Common operations are to delete the old certificates related to the server/client certificate, and then generate a new certificate. In this case, a shell script is compiled, which only needs to be periodically run on the Client side. Since the script involves a plaintext password, you can consider encrypting this script to improve security (refer to: http://lxsym.blog.51cto.com/1364623/768286)
#! /Bin/bash
# Re-issuing the puppet certificate for client exceptions
#2012/05/30 Richard Shen
SIP = "192.168.11.6" # server ip Address
SPASSWD = "hello" # server root password,
Host = 'hostname'
S_dns = ".dns.abc.com. pem" # The Host-IP address corresponding to the internal DNS resolution depends on the actual situation.
S_ca_name = "$ host $ s_dns" # $ host Certificate file on the server
R_NUM = '/usr/sbin/puppetd -- test -- server pup-ser-01.dns.abc.com | grep "notice: Finished" | wc-l'
[! -F/usr/bin/nc] & yum-y install nc
[! -F/usr/bin/keep CT] & yum-y install keep CT
# LOGIN PUPPET SERVER
Auto_smart_ssh (){
CT-c "set timeout-1;
Spawn ssh-o StrictHostKeyChecking = no $2 $ {@: 3 };
CT {
* Assword: * {send -- $1 \ r;
CT {
* Denied * {exit 2 ;}
Eof
}
}
Eof {exit 1 ;}
}
"
# Return $?
}
# Perform the following two operations to determine whether the operation is normal or not
I = 0
While [[$ I-lt 2]
Do
If [$ R_NUM-ne 1]; then
Rm-rf/var/lib/puppet/ssl /*
Auto_smart_ssh $ SPASSWD root @ $ SIP rm-rf/var/lib/puppet/ssl/ca/signed/$ s_ca_name
/Usr/sbin/puppetd -- test -- server pup-ser-01.dns.abc.com
Else
Echo "$ host puppet client is OK"

Fi
Let I = I + 1
Done
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.