# # # # # # # # # 1 .进入Es目录 # # # # # # # # # cd elasticsearch-release # # # # # # # 2 .为集群创建认证机构 # # # # # # # # # 依次输入回车(文件使用默认名),密码,并记住该密码 bin/elasticsearch-certutil ca # # # # # # # # 3 .为节点颁发证书 # # # # # # # # # # 遇提示依次输入步骤 2 的密码/回车/步骤 2 的密码 bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 # 输入第一步输入的密码 bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password # 输入第一步输入的密码 bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password # # # # # # # # 4 .http加密设置 # # # # # # # # # # 执行加密指令 bin/elasticsearch-certutil http # 后续操作请参考如下 ## Elasticsearch HTTP Certificate Utility The 'http' command guides you through the process of generating certificates for use on the HTTP (Rest) interface for Elasticsearch. This tool will ask you a number of questions in order to generate the right set of files for your needs. ## Do you wish to generate a Certificate Signing Request (CSR)? A CSR is used when you want your certificate to be created by an existing Certificate Authority (CA) that you do not control (that is, you don't have access to the keys for that CA). If you are in a corporate environment with a central security team, then you may have an existing Corporate CA that can generate your certificate for you. Infrastructure within your organisation may already be configured to trust this CA, so it may be easier for clients to connect to Elasticsearch if you use a CSR and send that request to the team that controls your CA. If you choose not to generate a CSR, this tool will generate a new certificate for you. That certificate will be signed by a CA under your control. This is a quick and easy way to secure your cluster with TLS, but you will need to configure all your clients to trust that custom CA. # pkcs模式,这里选择N Generate a CSR? [y/N]N ## Do you have an existing Certificate Authority (CA) key-pair that you wish to use to sign your certificate? If you have an existing CA certificate and key, then you can use that CA to sign your new http certificate. This allows you to use the same CA across multiple Elasticsearch clusters which can make it easier to configure clients, and may be easier for you to manage. If you do not have an existing CA, one will be generated for you. # 选择y Use an existing CA? [y/N]y ## What is the path to your CA? Please enter the full pathname to the Certificate Authority that you wish to use for signing your new http certificate. This can be in PKCS# 12 (.p12), JKS (.jks) or PEM (.crt, .key, .pem) format. # 输入步骤 3 产生的证书路径 CA Path: /home/envuser/elasticsearch-release/elastic-stack-ca.p12 Reading a PKCS12 keystore requires a password. It is possible for the keystore's password to be blank, in which case you can simply press <ENTER> at the prompt # 输入步骤 2 使用的密码 Password for elastic-stack-ca.p12: ## How long should your certificates be valid? Every certificate has an expiry date. When the expiry date is reached clients will stop trusting your certificate and TLS connections will fail. Best practice suggests that you should either: (a) set this to a short duration ( 90 - 120 days) and have automatic processes to generate a new certificate before the old one expires, or (b) set it to a longer duration ( 3 - 5 years) and then perform a manual update a few months before it expires. You may enter the validity period in years (e.g. 3Y), months (e.g. 18M), or days (e.g. 90D) # 回车,默认 5 年有效期 For how long should your certificate be valid? [5y] ## Do you wish to generate one certificate per node? If you have multiple nodes in your cluster, then you may choose to generate a separate certificate for each of these nodes. Each certificate will have its own private key, and will be issued for a specific hostname or IP address. Alternatively, you may wish to generate a single certificate that is valid across all the hostnames or addresses in your cluster. If all of your nodes will be accessed through a single domain (e.g. node01.es.example.com, node02.es.example.com, etc) then you may find it simpler to generate one certificate with a wildcard hostname (*.es.example.com) and use that across all of your nodes. However, if you do not have a common domain name, and you expect to add additional nodes to your cluster in the future, then you should generate a certificate per node so that you can more easily generate new certificates when you provision new nodes. # 选择N Generate a certificate per node? [y/N]N ## Which hostnames will be used to connect to your nodes? These hostnames will be added as "DNS" names in the "Subject Alternative Name" (SAN) field in your certificate. You should list every hostname and variant that people will use to connect to your cluster over http. Do not list IP addresses here, you will be asked to enter them later. If you wish to use a wildcard certificate ( for example *.es.example.com) you can enter that here. Enter all the hostnames that you need, one per line. When you are done, press <ENTER> once more to move on to the next step. # 依次输入节点的hostName,每个hostName占一行,输出完成后输入回车结束输入 elk-data6001 elk-data6002 elk-data6003 You entered the following hostnames. # 依次输入节点的ip,每个ip占一行,输出完成后输入回车结束输入 - elk-data6001 - elk-data6002 - elk-data6003 # 输入Y Is this correct [Y/n]Y ## Which IP addresses will be used to connect to your nodes? If your clients will ever connect to your nodes by numeric IP address, then you can list these as valid IP "Subject Alternative Name" (SAN) fields in your certificate. If you do not have fixed IP addresses, or not wish to support direct IP access to your cluster then you can just press <ENTER> to skip this step. Enter all the IP addresses that you need, one per line. When you are done, press <ENTER> once more to move on to the next step. 10.27 . 20.245 10.27 . 20.246 10.27 . 21.137 You entered the following IP addresses. - 10.27 . 20.245 - 10.27 . 20.246 - 10.27 . 21.137 # 输入Y Is this correct [Y/n]Y ## Other certificate options The generated certificate will have the following additional configuration values. These values have been selected based on a combination of the information you have provided above and secure defaults. You should not need to change these values unless you have specific requirements. Key Name: elk-data6001 Subject DN: CN=elk-data6001 Key Size: 2048 # 输入N Do you wish to change any of these options? [y/N]N ## What password do you want for your private key(s)? Your private key(s) will be stored in a PKCS# 12 keystore file named "http.p12" . This type of keystore is always password protected , but it is possible to use a blank password. If you wish to use a blank password, simply press <enter> at the prompt below. Provide a password for the "http.p12" file: [<ENTER> for none] # 输入回车 ## Where should we save the generated files? A number of files will be generated including your private key(s), public certificate(s), and sample configuration options for Elastic Stack products. These files will be included in a single zip archive. # 输入回车 What filename should be used for the output zip file? [/home/envuser/elasticsearch- 7.6 . 2 /elasticsearch-ssl-http.zip] Zip file written to /home/envuser/elasticsearch- 7.6 . 2 /elasticsearch-ssl-http.zip # # # # # # # # 5 .多节点配置 # # # # # # # # # # 解压证书 unzip elasticsearch-ssl-http.zip -d ssl # 为证书添加访问权限 chmod 644 elastic-certificates.p12 chmod 644 elastic-stack-ca.p12 # 将证书移动到config目录 mv ssl/elasticsearch/http.p12 config mv elastic-certificates.p12 config mv elastic-stack-ca.p12 config # 将证书和keystore文件scp到其他节点的Es config目录下 scp ssl/elasticsearch/http.p12 config/elastic-certificates.p12 config/elastic-stack-ca.p12 config/elasticsearch.keystore envuser @IP :/home/envuser/elasticsearch- 7.6 . 2 /config |