用于es生成ssl认证证书:

安装pexpect,ptyprocess模块
编写脚本使用pexpect

[root@master bin]# vim python.sh 

#!/usr/bin/env python
import pexpect

def main():
    c1 = pexpect.spawn('./elasticsearch-certutil ca')
    c1.expect('output file')
    c1.sendline()
    c1.expect('password')
    c1.sendline()
    c1.expect(pexpect.EOF)
    #print(c1.before)
    c2 = pexpect.spawn('./elasticsearch-certutil cert --ca elastic-stack-ca.p12')
    c2.expect('password for CA')
    c2.sendline()
    c2.expect('output file')
    c2.sendline()
    c2.expect('password for elastic')
    c2.sendline()
    c2.expect(pexpect.EOF)
    #print(c2.before)
if __name__ == '__main__':
    main()
 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐