Method, device and storage medium for repairing server secret-free mutual trust
By obtaining the node to be detected in the server cluster, performing password-free connection and password verification, and repairing the configuration file problem based on preset configuration files, solving the problem of inefficient quick repair of password-free mutual trust failure, and achieving efficient password-free connection repair. Restrictions on dependence on additional servers in the prior art are avoided.
Patent Information
- Application Number
- CN202411092057.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2044-08-09
AI Technical Summary
In server clusters, the failure of password-free mutual trust causes inter-node communication to be affected, manual troubleshooting of problem nodes is inefficient, and the existing technology relies on additional servers or shared directories, limiting the universality of repairs.
By obtaining the node to be detected in the server cluster corresponding to the target node, performing password-free connection processing, and sending password verification information for consistency verification, repairing the original configuration file of the node based on the preset target configuration file, realizing rapid repair.
It realizes efficient detection and repair of the problem of password-free connection failure between server nodes, improves repair efficiency, does not rely on additional servers, and is highly versatile.
Smart Images

Figure CN118646595B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of operation and maintenance technology, and in particular to a method, device and storage medium for repairing server mutual trust without password. Background Art
[0002] Password-free mutual trust is a technology that allows different servers to communicate with each other without the need for account and password authentication. Its basic principle is to generate a pair of public and private keys; then add the generated public key to the authorization file of the target server. When the user tries to log in to the target server remotely through OpenSSH, the server will verify whether the public key sent by the user is in the authorization file. If the verification is successful, the server will use the private key corresponding to the public key for authentication, thereby achieving password-free login.
[0003] At present, the realization of mutual trust between server cluster nodes is one of the foundations for the normal operation and operation and maintenance automation of most programs. However, once the mutual trust between some nodes in the server cluster has problems, the communication between the nodes will be affected, resulting in abnormal functions of the entire cluster.
[0004] Since server clusters often involve many nodes, relying on technicians to manually troubleshoot problem nodes is very error-prone and the troubleshooting efficiency is very low. Summary of the invention
[0005] The present application at least provides a method, apparatus, device and computer-readable storage medium for repairing server mutual trust without password.
[0006] In a first aspect, the present application provides a method for repairing password-free mutual trust of a server, and the method is applied to a target node in a server cluster, comprising: obtaining a node to be detected in the server cluster corresponding to the target node; performing password-free connection processing between the target node and the node to be detected to obtain a password-free connection result; in response to the password-free connection result indicating that there is a node to be detected that fails to connect to the password-free node, sending password verification information to each node to be detected to perform password consistency verification; in response to the verification result fed back by each node to be detected indicating that the passwords between the target node and each node to be detected are consistent, performing file repair processing on the original configuration file in each node based on a preset target configuration file to obtain a repaired node.
[0007] In one embodiment, the performing file repair processing on the original configuration file in each node based on a preset target configuration file to obtain a repaired node includes: performing file repair processing on the original configuration file in the target node based on the target configuration file to obtain a repaired target node; sending the target configuration file to each node to be detected, so that each node to be detected performs file repair processing on the original configuration file in the corresponding node based on the received target configuration file to obtain each repaired node to be detected.
[0008] In one embodiment, the file repair processing is performed on the original configuration file in the target node based on the target configuration file to obtain the repaired target node, including: replacing the original configuration file in the target node with the target configuration file to obtain the replaced file in the target node; detecting whether the replaced file in the target node is compatible with the target node; if compatible, loading the replaced file into the target node to obtain the repaired target node.
[0009] In one embodiment, replacing the original configuration file in the target node with the target configuration file to obtain the replaced file in the target node includes: backing up the original configuration file in the target node to obtain the backup configuration file; replacing the original configuration file in the target node based on the target configuration file to obtain the replaced file in the target node; after detecting whether the replaced file in the target node is compatible with the target node, the method further includes: if not compatible, using the backup configuration file corresponding to the target node to perform a restore process.
[0010] In one embodiment, the target configuration file includes an encryption protocol installation package, and the detecting whether the replaced file in the target node is compatible with the target node includes: obtaining version information of the encryption protocol installation package; judging whether the encryption protocol installation package is compatible with the target node based on the version information of the encryption protocol installation package; after the detecting whether the replaced file in the target node is compatible with the target node, the method further includes: in response to the encryption protocol installation package being compatible with the target node, installing the encryption protocol installation package on the target node.
[0011] In one embodiment, the password verification information includes a server password, and in response to the password-free connection result indicating that there is a node to be detected that fails to connect to the password-free connection, the password verification information is sent to each node to be detected for password consistency verification, including: performing a password authentication connection on each node to be detected based on the server password; if the connection with each node to be detected is successful, it indicates that the passwords between the target node and each node to be detected are consistent; if there is a node among the nodes to be detected that fails to connect, it indicates that the passwords of each node are inconsistent, the node that failed to connect is fed back, and the repair is paused or stopped.
[0012] In one embodiment, obtaining the node to be detected corresponding to the target node in the server cluster includes: obtaining each initial node corresponding to a preset node type in the server cluster; merging and deduplicating the node addresses of each initial node corresponding to the preset node type to obtain a processed node address; and determining the node corresponding to the processed node address as the node to be detected.
[0013] In one embodiment, before performing file repair processing on the original configuration file in each node based on the preset target configuration file to obtain the repaired node, the method further includes:
[0014] Extracting quantity information and text description information of the target configuration file; performing file verification processing on the target configuration file based on the quantity information and the text description information to obtain a file verification result; if the file verification result indicates that the target configuration file meets a preset file standard, performing file repair processing based on the target configuration file.
[0015] The second aspect of the present application provides a device for repairing server password-free mutual trust, including: an acquisition module, used to obtain a node to be detected corresponding to the target node in the server cluster; a password-free connection module, used to perform a password-free connection process between the target node and the node to be detected to obtain a password-free connection result; a password verification module, used to send password verification information to each node to be detected for password consistency verification in response to the password-free connection result indicating that there is a node to be detected that fails to connect to the password-free connection; a repair module, used to perform file repair processing on the original configuration file in each node based on a preset target configuration file in response to the verification result fed back by each node to be detected indicating that the passwords between the target node and each node to be detected are consistent, to obtain a repaired node.
[0016] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned method for repairing server mutual trust without password.
[0017] A fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implements the above-mentioned method for repairing server mutual trust without password.
[0018] The above scheme obtains the node to be detected corresponding to the target node in the server cluster; performs password-free connection processing between the target node and the node to be detected to obtain a password-free connection result, thereby being able to characterize whether the target node and each node to be detected can normally perform a password-free connection through the password-free connection result; in response to the password-free connection result characterizing that there is a node to be detected that fails to perform a password-free connection, password verification information is sent to each node to be detected for password consistency verification to determine whether the reason for the failure of the password-free connection is due to inconsistent passwords of each node; in response to the verification result fed back by each node to be detected characterizing that the passwords between the target node and each node to be detected are consistent, it is determined that there may be a problem with the configuration file of each node that caused the failure of the password-free connection, and therefore, the original configuration file in each node is repaired based on the preset target configuration file to obtain a repaired node; thereby achieving efficient detection of the problem of failed password-free connections between server nodes and rapid repair of password-free connections.
[0019] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0021] Figure 1 It is a flowchart of an exemplary embodiment of the method for repairing server mutual trust without password of the present application;
[0022] Figure 2 It is a block diagram of a device for repairing server mutual trust without passwords, shown in an exemplary embodiment of the present application;
[0023] Figure 3 It is a structural schematic diagram of an embodiment of the electronic device of the present application;
[0024] Figure 4 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0025] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0026] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0027] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0028] Password-free mutual trust is a method that uses key pairs to communicate between different servers without account password authentication. Its basic principle is to first generate a pair of public and private keys, and then add the generated public key to the authorization file of the target server. When the user tries to log in to the target server remotely through OpenSSH, the server will verify whether the public key sent by the user is in the authorization file. If the verification is successful, the server will use the private key corresponding to the public key for authentication, thereby achieving password-free login. Realizing password-free mutual trust between server cluster nodes is already one of the foundations for the normal operation and operation and maintenance automation of most current programs. Once the password-free mutual trust of some nodes has problems, the communication between the nodes is affected, which will cause the function of the entire cluster to be abnormal. Since server clusters often involve many nodes, manual troubleshooting of problem nodes is very error-prone and inefficient.
[0029] At present, in the configuration, detection and repair methods for the server secret-free mutual trust method, for example, it is necessary to use an additional server to deploy a shared directory for storing public keys, and use the shared directory to achieve mutual secret-free between multiple servers. If there is a problem with the public key stored in the shared directory, it will directly affect all servers. Another example is to use multiple additional servers to implement a secret-free mutual trust configuration system, based on which other servers can be configured for secret-free mutual trust, which also has certain limitations in actual use.
[0030] In response to the deficiencies in the prior art, this application proposes a method for repairing server password-free mutual trust, detects and analyzes various causes of failure of password-free mutual trust between server nodes, and performs rapid repairs. At the same time, the password-free mutual trust repair process does not require reliance on additional servers and is highly versatile.
[0031] See also Figure 1 , Figure 1 This is a flowchart of an exemplary embodiment of the method for repairing server mutual trust without password of the present application. Specifically, it may include the following steps:
[0032] Step S110, obtaining the node to be detected corresponding to the target node in the server cluster.
[0033] Among them, the server cluster may include multiple nodes, and multiple nodes can provide the same or different types of services, which is not limited here. In the present application, the selected target node can be the console node of the server cluster. The method of the present application can mainly involve executable script files (such as shell scripts or python scripts commonly used in server application environments or other types of scripts, which are not limited here, and the following text mainly uses shell scripts as an example for explanation), and also involves target configuration files for configuration file replacement. By executing the shell script on the console node, the console node will perform steps including but not limited to environment detection, password acquisition, cluster node acquisition, password-free detection and password-free repair, which are not repeated here.
[0034] Specifically, if the target node (console node) wants to perform a non-confidential mutual trust test on other nodes to be tested in the server cluster, it needs to first obtain the nodes to be tested corresponding to the target node in the server cluster, such as obtaining the node IP addresses of all nodes in the server cluster.
[0035] Step S120, performing a password-free connection process between the target node and the node to be detected to obtain a password-free connection result.
[0036] The processing of password-free connection can refer to the existing password-free connection method, which will not be described here. For example, the target node performs a password-free connection to all nodes to be detected in the server cluster based on the obtained ssh command. Among them, ssh (secure shell) refers to an encrypted network protocol that can be used for encrypted login between computers, servers and other devices. There are two basic modes of ssh command, one is to log in to a remote machine (such as a server node), and the other is to execute code on the remote machine.
[0037] In the present application, if the result of the secret-free connection is that the target node successfully performs a secret-free connection to each node to be detected in the cluster based on the ssh command, it indicates that the secret-free mutual trust between the nodes in the current server cluster is in a normal state, and the subsequent detection and repair process can be directly ended. If the result of the secret-free connection is that the target node performs a secret-free connection to each node to be detected in the cluster based on the ssh command, and the secret-free connection of some or all nodes in the cluster fails, it indicates that the secret-free mutual trust between the nodes in the current server cluster has failed and is in an abnormal state, and the connection failure information can be written into the secret-free connection result file; by analyzing the secret-free connection result file, if there is connection failure information, it means that the secret-free connection needs to be repaired.
[0038] It should be noted that in the process of the secret-free connection processing, all nodes in the server cluster may be connected to a secret-free connection, which may specifically include a secret-free connection between the target node and each node to be detected, and a secret-free connection between each node to be detected.
[0039] Step S130, in response to the password-free connection result indicating that there are nodes to be detected that have failed the password-free connection, password verification information is sent to each node to be detected to perform password consistency verification.
[0040] In conjunction with the above steps, if the password-free connection result indicates that the password-free connection of some or all nodes to be detected in the current server cluster fails, it is necessary to use a password to access each node to verify the password consistency between the nodes.
[0041] For example, you can use the expect command and ssh command to perform password authentication connection for all nodes in the cluster. Among them, the expect command is a command used to handle interactions, and is mainly used in scenarios of automated interactive operations, such as writing interactive processes such as ssh login and ftp login in a script to automate them. In addition, there are other related commands in expect, such as: spawn: start a new process; send: used to send a string to a process, reply function; expect: receive a string from a process, listen function; interact: allow user interaction, etc., which will not be repeated here.
[0042] That is, the target node can send the password verification information to each node to be detected through the expect command and the ssh command for password authentication connection. Wherein, the password verification information may include but is not limited to the password, key or other verification information for accessing the server node, etc., which is not limited here. Each node to be detected performs password verification after receiving the password verification information. If the password is correct, the password connection is successful, otherwise if the password is wrong, the password connection fails. If there is a node to be detected that fails to connect, the information representing the inconsistent passwords will be written into the password verification result file and returned to the target node accordingly. The target node can be detected based on the received password verification result file. If the inconsistent information of the password is detected in the password verification result file, the password of the node to be detected corresponding to the password verification result file is inconsistent, and it is not a problem of failure of the password-free connection. Therefore, the problem of inconsistent passwords can be generated into a corresponding text string and a text display process and / or voice prompt process can be performed, and the subsequent free password detection repair process is terminated.
[0043] It should be noted that the purpose of verifying password consistency in this application is mainly to verify whether each node in the current server cluster can be accessed with the same password. If so, password-free mutual trust can be achieved based on the same password. If not, password-free mutual trust cannot be achieved.
[0044] It should also be noted that the various executable commands used in the method of the present application may be pre-set in the executable script, or may be received from the user in real time during the execution of the method of the present application, which is not limited here.
[0045] Step S140, in response to the verification results fed back by the nodes to be detected indicating that the passwords between the target node and the nodes to be detected are consistent, the original configuration files in each node are repaired based on the preset target configuration files to obtain repaired nodes.
[0046] In combination with the above steps, if the verification results fed back by the target node and the nodes to be detected indicate that the passwords between the target node and the nodes to be detected are consistent, it means that the nodes in the server cluster can access each other using the same password, that is, the reason why the password-free connection of the nodes in the server cluster failed may be because there is a problem with the configuration files of each node.
[0047] Among them, the configuration file of the present application may refer to one or more configuration files including but not limited to OpenSSH installation package, OpenSSH configuration file, PAM configuration file, etc. OpenSSH is a free and open source implementation of the ssh protocol. OpenSSH provides server-side background programs and client tools that can be used to encrypt data during remote control and file transfer. It allows administrators of Linux and other non-Windows systems to manage remote systems across platforms, which is one of the basic configurations for realizing the environment of secret-free mutual trust in server clusters. PAM (Pluggable Authentication Modules) is a commonly used authentication mechanism currently. By providing some dynamic link libraries and a unified API, the services provided by the system and the authentication methods of the services are separated, so that system administrators can flexibly configure different authentication methods for different services as needed without changing the service program. At the same time, it is also convenient to add new authentication methods to the system. It usually includes authentication management, account management, password management and session management, and is also one of the basic configurations for realizing the environment of secret-free mutual trust in server clusters.
[0048] Therefore, in response to the verification results fed back by each node to be detected indicating that the passwords between the target node and each node to be detected are consistent, the target node will perform file repair processing on the original configuration files in each node based on the preset target configuration file to obtain a repaired node. The file repair processing may include but is not limited to replacing the original configuration file based on the target configuration file, and loading the replaced target configuration file, etc., which will not be elaborated here.
[0049] It can be understood that the repaired nodes can access each other based on the same password, and the repaired nodes have the same configuration file; therefore, the repaired nodes can be processed for password-free connection again to verify whether the password-free connection between the nodes in the server cluster is successfully repaired.
[0050] It can be seen that the present application obtains the node to be detected corresponding to the target node in the server cluster; performs password-free connection processing between the target node and the node to be detected to obtain a password-free connection result, thereby being able to characterize whether the target node and each node to be detected can normally perform a password-free connection through the password-free connection result; in response to the password-free connection result characterizing that there is a node to be detected that fails to make a password-free connection, password verification information is sent to each node to be detected for password consistency verification to determine whether the reason for the failure of the password-free connection is due to inconsistent passwords of each node; in response to the verification result fed back by each node to be detected characterizing that the passwords between the target node and each node to be detected are consistent, it is determined that there may be a problem with the configuration file of each node that caused the failure of the password-free connection, and therefore, based on the preset target configuration file, the original configuration file in each node is repaired to obtain a repaired node; thereby achieving efficient detection of the problem of failed password-free connections between server nodes and rapid repair of password-free connections.
[0051] Based on the above embodiment, the embodiment of the present application describes the steps of performing file repair processing on the original configuration file in each node based on the preset target configuration file to obtain the repaired node. Specifically, the method of this embodiment includes the following steps:
[0052] Based on the target configuration file, the original configuration file in the target node is repaired to obtain the repaired target node; the target configuration file is sent to each node to be detected, so that each node to be detected performs file repair processing on the original configuration file in the corresponding node based on the received target configuration file to obtain each repaired node to be detected.
[0053] In conjunction with the foregoing embodiment, in the process of performing file repair processing on the original configuration file in each node based on the preset target configuration file, the file repair processing can be performed on the original configuration files of all nodes in the current server cluster, that is, it includes performing file repair processing on the original configuration file of the target node itself, and performing file repair processing on the original configuration files of other nodes to be detected in the server cluster.
[0054] Specifically, the target node will perform file repair processing on the original configuration file in the target node based on the acquired target configuration file to obtain the repaired target node; and the target node will send the target configuration file to the nodes to be detected in the server cluster, so that each node to be detected performs file repair processing on the original configuration file in its own node based on the received target configuration file to obtain each repaired node to be detected. Therefore, the repaired target node and each repaired node to be detected have the same configuration file, that is, each node in the server cluster has the environment configuration foundation for realizing non-confidential mutual trust interaction.
[0055] Based on the above embodiment, the embodiment of the present application describes the steps of performing file repair processing on the original configuration file in the target node based on the target configuration file to obtain the repaired target node. Specifically, the method of this embodiment includes the following steps:
[0056] The original configuration file in the target node is replaced with the target configuration file to obtain the replaced file in the target node; whether the replaced file in the target node is compatible with the target node is detected; if compatible, the replaced file is loaded into the target node to obtain a repaired target node.
[0057] In conjunction with the foregoing embodiments, the method for repairing server password-free mutual trust of the present application will perform file repair processing on the configuration files of all nodes in the server cluster, including repairing the configuration files in the target node and repairing the configuration files in the node to be detected.
[0058] For ease of explanation, an application scenario of repairing the configuration file in the target node is used as an example for illustrative explanation. The target node can replace the original configuration file in the target node (the old configuration file currently in use) with the acquired target configuration file (the newly acquired configuration file) to obtain the replaced file in the target node; the target node then detects whether the replaced file is compatible with the target node itself, such as whether the version information meets the requirements, whether the quantity information meets the requirements, whether the file name meets the requirements, etc., which are not limited here; if the target node is compatible with the replaced file in the target node, the target node can load and use the replaced file to obtain a repaired target node.
[0059] Similarly, the configuration file replacement process of other nodes to be detected in the server cluster can also refer to the above example. After receiving the target configuration file sent by the target node, each node to be detected will replace the original configuration file in its own node with the received target configuration file. Each node to be detected will then determine whether it is compatible based on the replaced configuration file in its own node. If it is compatible, each node to be detected will load the replaced configuration file in its own node to obtain a repaired node to be detected.
[0060] Based on the above embodiment, the embodiment of the present application describes the steps of replacing the original configuration file in the target node with the target configuration file to obtain the replaced file in the target node. Specifically, the method of this embodiment includes the following steps:
[0061] The original configuration file in the target node is backed up to obtain a backup configuration file; the original configuration file in the target node is replaced based on the target configuration file to obtain a replaced file in the target node; after detecting whether the replaced file in the target node is compatible with the target node, the method further includes: if not compatible, restoring the file using the backup configuration file corresponding to the target node.
[0062] Among them, backup processing is a fault-tolerant mechanism that can be used for each node after the configuration file is replaced. If a node is incompatible with the configuration file, it can be rolled back to the configuration before the file replacement based on the backup configuration file obtained by the backup processing.
[0063] First, take the target node as an example. When the target node replaces the configuration file, the original configuration file in the node can be backed up first, including but not limited to backing up the / etc / pam.d, / etc / ssh and / home / ${User} / .ssh configuration files to obtain the backup configuration file. The target node then uses the target configuration file to replace the original configuration files of / etc / pam.d, / etc / ssh and / home / ${User} / .ssh, and modifies the corresponding access rights. The access rights refer to the user User can access the configuration file with the corresponding permissions. Therefore, after replacing the configuration file, the user's access permissions to the configuration file (such as read and write permissions) need to be modified to ensure the normal execution of the subsequent processing. Then the target node checks whether the configuration file is compatible based on the obtained sshd command. sshd (ssh daemon) is the core program in the OpenSSH suite, which is mainly used as the daemon process of the OpenSSH server. The sshd service can be started by the sshd command to determine whether the configuration files in the current node and the current node are compatible. If the target node and the replaced configuration files in the target node are compatible, the target node will load its replaced configuration file. If they are not compatible, the target node will roll back the configuration and use the previous backup configuration file to restore the configuration to the original configuration before the configuration file was replaced.
[0064] Similarly, after receiving the target configuration file sent by the target node, each node to be detected in the server cluster will first back up the original configuration files in their respective nodes, such as / etc / pam.d, / etc / ssh, and / home / ${User} / .ssh configuration files, to obtain the backup configuration files of each node to be detected. Then, each node to be detected will replace the original configuration files in its respective nodes (such as / etc / pam.d, / etc / ssh, and / home / ${User} / .ssh original configuration files) based on the received target configuration file, and modify the corresponding access rights. Then, each node to be detected will also check whether the configuration files are compatible based on the obtained sshd command. For each node to be detected, if a node to be detected is compatible with the replaced configuration files in its own node, the node to be detected will load the replaced configuration files in its own node. If the node to be detected is incompatible, the node to be detected will roll back the configuration and use the previous backup configuration file to restore the configuration to the original configuration before the configuration file was replaced; or if there is at least one node to be detected that is incompatible, all nodes in the server cluster will use their corresponding backup configuration files to restore the configuration.
[0065] Based on the above embodiment, the embodiment of the present application describes the steps of detecting whether the replaced file in the target node is compatible with the target node. Among them, the target configuration file includes an encryption protocol installation package. Specifically, the method of this embodiment includes the following steps:
[0066] Obtaining version information of the encryption protocol installation package; judging whether the encryption protocol installation package is compatible with the target node based on the version information of the encryption protocol installation package; after detecting whether the replaced file in the target node is compatible with the target node, the method further includes: in response to the encryption protocol installation package being compatible with the target node, installing the encryption protocol installation package on the target node.
[0067] In conjunction with the foregoing embodiment, the target configuration file includes, in addition to the OpenSSH configuration file, PAM configuration file, etc. in the foregoing embodiment, an encryption protocol installation package. In this application scenario, the SSH encryption protocol is used to implement password-free mutual trust, so the encryption protocol installation package is also the OpenSSH installation package.
[0068] It should be noted that, in the step of detecting whether the replaced file in the target node is compatible with the target node, the OpenSSH version is usually replaced first, and then the compatibility of OpenSSH is detected, and then the other configuration files in the above embodiment are replaced, and then the compatibility of the other configuration files is detected.
[0069] For example, the target node obtains the version information of glibc that it depends on based on the obtained ldd command, grep command and awk command. Among them, the ldd command is mainly used to check the dynamic link library that the executable file or shared library file depends on, determine whether the library file required for program operation exists and whether the version matches, so as to troubleshoot library dependency problems; the grep command is used to search for lines that match regular expressions in one or more input files, and output the matching lines to the standard, which is equivalent to performing string matching search; the awk command browses and extracts text information in files or strings based on specified rules, and performs text processing operations after extracting the text information; glibc is the lowest-level API in the Linux system, and almost any other runtime library will depend on glibc. Therefore, before replacing the configuration file, each node needs to first detect whether its current glibc version meets the requirements, such as text matching the version information of the OpenSSH installation package and the glibc version information, or text matching the preset version information and the glibc version information. If the match is successful, it means that the requirements are met, that is, the OpenSSH installation package is compatible with the target node; if the match fails, it means that the requirements are not met, indicating that the OpenSSH installation package and the target node are incompatible, and it is necessary to exit the password-free repair process. In response to the OpenSSH installation package being compatible with the target node, the target node can install the OpenSSH installation package on the target node based on the obtained rpm command. Among them, the rpm command is mainly used for operations such as installing, upgrading, querying and deleting software packages on the Linux system. After the OpenSSH version is successfully replaced, other configuration files (such as OpenSSH configuration files, PAM configuration files, etc.) can continue to be replaced.
[0070] In another exemplary embodiment, after receiving the target configuration file sent by the target node, other nodes to be detected will also refer to the example description of the above target node, first obtain the glibc version on which they depend based on the ldd command, grep command and awk command, and then determine whether the OpenSSH installation package in the target configuration file conforms to the gblic version of each server node to determine whether the received OpenSSH installation package is compatible with their own nodes. If compatible, each node to be detected installs a unified version of OpenSSH based on the obtained rpm command. This achieves that each node in the entire server cluster runs the replaced OpenSSH with the same version. Then each node replaces other configuration files in its own node, etc., as described in the above embodiment, which will not be repeated here.
[0071] It should also be noted that since the nodes in the server cluster failed to connect without a password in the previous implementation process, there is a warning message of the failure of the password-free connection in each node. Therefore, after the configuration files of each node in the current server cluster are replaced and loaded, each node in the server cluster should also need to clean up the / home / ${User} / .ssh / known_hosts file in the node based on the rm command to repair the warning message and avoid affecting the subsequent password-free mutual trust connection process.
[0072] Further, after the OpenSSH version replacement, the non-confidential configuration file replacement, and the warning information repair of the aforementioned embodiment, the target node can perform concurrent non-confidential connections to all nodes in the current server cluster based on the ssh command. If all nodes in the server cluster are successfully connected without a secret, it indicates that the repair of the previous non-confidential connection failure problem is successful. If there are still some nodes or all nodes in the server cluster that fail to connect without a secret, it indicates that the non-confidential connection of the nodes that failed to connect without a secret is invalid, and the connection failure information of the nodes that failed to connect without a secret can be written into the current connection result file and fed back to the target node. After receiving the connection result file, the target node performs content detection and analysis on the connection result file. If it is found that there is still connection failure information in the connection result file, it means that the non-confidential repair has failed, and the repair failure information can be output and the current repair process can be exited.
[0073] Based on the above embodiment, the embodiment of the present application describes the steps of sending password verification information to each node to be detected for password consistency verification in response to the result of the password-free connection indicating that there is a node to be detected that fails to connect to the password-free connection. The password verification information may include a server password. Specifically, the method of this embodiment includes the following steps:
[0074] Perform password authentication connection for each node to be detected based on the server password; if the connection with each node to be detected is successful, it indicates that the passwords between the target node and each node to be detected are consistent; if there are nodes among the nodes to be detected that fail to connect, it indicates that the passwords of each node are inconsistent, and the nodes that fail to connect will be fed back and paused or stopped for repair.
[0075] In conjunction with the above-mentioned embodiment, when the password-free connection of each node in the server cluster fails, unified password verification information should be used in the server cluster to perform password consistency verification.
[0076] Exemplarily, the target node performs a password-free connection to all nodes in the cluster based on the ssh command. If a node fails to connect, it indicates that the corresponding node is password-free and invalid. The password-free invalid node will write the connection failure information into the connection result file and feedback to the target node. The target node detects and analyzes the received connection result file. If there is connection failure information in the connection result file, it means that the password-free mutual trust connection in the current server cluster needs to be repaired, and then password consistency verification is performed. The target node performs password authentication connection to all nodes in the cluster based on the expect command and the ssh command. If a node fails to connect, it means that the password of the corresponding node is wrong. The password error node will write the password inconsistency information into the verification result file and feedback to the target node. The target node will detect and analyze the received verification result file. If there is password inconsistency information in the verification result file, it means that the passwords of some or all nodes in the server cluster are inconsistent, so the password-free repair cannot be achieved, then the password inconsistency information is output for prompting, and the subsequent password-free repair process is exited.
[0077] It should be noted that the method for the target node to obtain password verification information may include but is not limited to: if there is a pre-specified server password when running the shell script file of this method, the specified password is used to perform password authentication connection on other nodes in the server cluster. If there is no specified password, it is detected whether there is a password change tool in the target node or the server cluster. The password change tool is used to change the server default password. If there is a password change tool, it indicates that the current default password of the server has been modified, so the server password can be obtained based on the password change tool. If there is no password change tool, the server default password is used.
[0078] Based on the above embodiment, the embodiment of the present application describes the steps of obtaining the node to be detected corresponding to the target node in the server cluster. Specifically, the method of this embodiment includes the following steps:
[0079] Acquire each initial node corresponding to a preset node type in the server cluster; merge and de-duplicate the node addresses of each initial node corresponding to the preset node type to obtain a processed node address; and determine the node corresponding to the processed node address as the node to be detected.
[0080] In conjunction with the above embodiments, there are usually multiple server nodes in a server cluster, and different nodes may provide the same or different services. Therefore, when obtaining the node to be detected corresponding to the target node in the server cluster, the target node needs to determine the corresponding node to be detected in the server cluster through the node IP address.
[0081] Specifically, if there are one or more pre-specified server node IPs when running the shell script file of this method, the target node determines the node to be detected in the server cluster based on these node IPs. If there is no pre-specified node IP, a method of automatically obtaining the node IP by using a script can be used to obtain the initial node IP based on the preset node type. The preset node type may include, but is not limited to, a query service node, a console node, an access service node, an MPP (Massively Parallel Processing) node, an ES (Elastic Search) node, and the like.
[0082] Exemplarily, for the target node, the method for obtaining the query service node IP can be based on the grep command, awk command, cut command (a command used to extract fields from a file or standard input and output them to the standard output) and base64 command (used to encode or decode a file or standard input into a standard output) to read the MySQL virtual IP, account, and password from the server's console configuration file; then, based on the MySQL virtual IP, account, and password, connect to the corresponding MySQL, and execute SQL statements to obtain the virtual IP responsible for providing query services; then the target node connects to the query service virtual IP based on the ssh command, and uses the grep command and awk command to obtain all node IPs providing query services from the query service configuration file.
[0083] A method for obtaining the IP address of a console node may be to read the IP addresses of all console nodes from a console configuration file based on the grep command and the awk command.
[0084] The method for obtaining the access service node IP address may be to read the IP addresses of all nodes providing access services from the console configuration file based on the grep command and the awk command.
[0085] The method for obtaining the MPP node IP is to read the MPP virtual IP from the console configuration file based on the grep command and the awk command; query the service virtual IP through the ssh command connection, and then use the grep command and the awk command to read the node IP of all MPP nodes from the MPP configuration file.
[0086] The method for obtaining the ES node IP is to read some node IPs of the ES cluster from the console configuration file based on the grep command and the awk command; and then obtain all node IPs of the ES cluster through the _cat / nodes interface.
[0087] In summary, the target node can obtain multiple node IPs (initial node IPs) through various services and configuration files, but these node IPs may have duplicate IPs. Therefore, it is necessary to merge and deduplicate the node addresses of each initial node, build the IP set of the server cluster, and obtain the processed node address; then determine the node corresponding to the processed node address as the node to be detected.
[0088] Specifically, the target node merges all acquired node IPs, and constructs an IP set containing all node IPs based on each node IP; uses the echo command, sed command, and uniq command to delete duplicate IPs in the IP set, obtains the processed node IP addresses, and uses the nodes corresponding to these IPs as nodes to be detected. Among them, the echo command is mainly used to output text or variable commands in the terminal (console), the sed command is mainly used to store the currently processed data in a temporary buffer, and the uniq command is used to delete or count duplicate data. In addition, the node IPs in the IP set can be sorted based on the echo command, sed command, and sort command, so as to process and observe and analyze in an orderly manner.
[0089] Based on the above embodiment, the embodiment of the present application describes the steps before the original configuration file in each node is repaired based on the preset target configuration file to obtain the repaired node. Specifically, the method of this embodiment includes the following steps:
[0090] Extracting quantity information and text description information of the target configuration file; performing file verification processing on the target configuration file based on the quantity information and the text description information to obtain a file verification result; if the file verification result indicates that the target configuration file meets a preset file standard, performing file repair processing based on the target configuration file.
[0091] With reference to the foregoing embodiments, in the present application, before performing file repair processing on the original configuration files in each node, an environmental detection process may also be performed, the purpose of which is to ensure that the subsequent password-free repair process will not fail to successfully perform the password-free repair due to environmental configuration errors.
[0092] Exemplarily, the target node may first perform a system version check, for example, based on the uname command and the grep command, to determine whether the system version information of the node itself or other nodes in the cluster meets the preset system version information (such as CentOS6, CentOS7 or OpenEuler system versions), where the uname command is mainly used to display the name of the current operating system. If it does not meet the preset system version information, it may represent that the executable script tool does not support the execution of the system, so the subsequent process will not be executed, and a prompt message indicating that the system version does not meet the requirements may be generated and the script program will be exited.
[0093] Furthermore, if the system version detection is passed, the target configuration files such as the OpenSSH installation package are detected. For example, the number of OpenSSH installation packages is checked to see if it meets the preset number standard through the ls command (displaying the file directory) and the wc command (displaying the number of files in the file directory) to achieve quantity verification. If it does not meet the preset number standard, it indicates that there is a problem with the number of the target configuration files, and it is necessary to feedback the problem (which can be displayed on the console by generating a prompt message) and exit the script program. If it meets the preset number standard, the version information (text description information of the version name) of the OpenSSH installation package can be checked to see if it meets the preset version standard through the ls command, the awk command, and the wc command to achieve version verification. If the version of the OpenSSH installation package does not meet the preset version standard, it is also necessary to feedback the problem and exit the script program. If the version of the OpenSSH installation package meets the preset version standard, the OpenSSH configuration file can be further tested.
[0094] For example, to detect the port number in the target configuration file, use the cat command (display file contents), grep command, and wc command to detect the port number in the target configuration file. If there are multiple port numbers in the OpenSSH configuration file, subsequent processing cannot be performed for the time being. You need to report the problem and exit the script. If there is only one port number in the OpenSSH configuration file, you can use the sed command to modify the port number in the target configuration file so that the port number recorded in the target configuration file required for each node is consistent with the port number of each node.
[0095] In summary, the method of the present application can quickly repair the problem of invalidation of mutual trust in server clusters caused by key expiration, OpenSSH configuration error, PAM configuration error, inconsistent OpenSSH versions, known_hosts warning information, etc. In addition, the password-free repair process of the present application can be run in the console node of the server cluster where the mutual trust in the password-free system has failed, without relying on an additional server, and is more versatile.
[0096] It should be further explained that the execution subject of the method for repairing the server's mutual trust without secrets may be a device for repairing the server's mutual trust without secrets. For example, the method for repairing the server's mutual trust without secrets may be executed by a terminal device or a server or other processing device, wherein the terminal device may be a user equipment (UE), a computer, a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the method for repairing the server's mutual trust without secrets may be implemented by a processor calling a computer-readable instruction stored in a memory.
[0097] Figure 2 FIG. 1 is a block diagram of an apparatus for repairing a server without password mutual trust, as shown in an exemplary embodiment of the present application. Figure 2 As shown, the exemplary apparatus 200 for repairing server mutual trust without password includes: an acquisition module 210, a password-free connection module 220, a password verification module 230 and a repair module 240. Specifically:
[0098] The acquisition module 210 is used to acquire the node to be detected corresponding to the target node in the server cluster.
[0099] The password-free connection module 220 is used to perform a password-free connection process between the target node and the node to be detected to obtain a password-free connection result.
[0100] The password verification module 230 is configured to send password verification information to each node to be detected for password consistency verification in response to the password-free connection result indicating that there is a node to be detected that has failed the password-free connection.
[0101] The repair module 240 is used to perform file repair processing on the original configuration file in each node based on a preset target configuration file in response to the verification result fed back by each node to be detected indicating that the passwords between the target node and each node to be detected are consistent, so as to obtain a repaired node.
[0102] In this exemplary device for repairing server password-free mutual trust, a node to be detected corresponding to a target node in a server cluster is obtained; a password-free connection process is performed between the target node and the node to be detected to obtain a password-free connection result, thereby being able to characterize whether a password-free connection can be normally performed between the target node and each node to be detected through the password-free connection result; in response to the password-free connection result characterizing that there is a node to be detected that fails to make a password-free connection, password verification information is sent to each node to be detected for password consistency verification to determine whether the reason for the failure of the password-free connection is due to inconsistent passwords of each node; in response to the verification result fed back by each node to be detected characterizing that the passwords between the target node and each node to be detected are consistent, it is determined that the failure of the password-free connection may be caused by a problem with the configuration file of each node, and therefore, file repair processing is performed on the original configuration file in each node based on the preset target configuration file to obtain a repaired node; thereby achieving efficient detection of the problem of failed password-free connections between server nodes and rapid repair of password-free connections.
[0103] It should be noted that the device provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0104] Among them, the functions of each module can be found in the implementation example of the method for repairing the server's password-free mutual trust, which will not be repeated here.
[0105] See also Figure 3 , Figure 3 300 includes a memory 301 and a processor 302, and the processor 302 is used to execute the program instructions stored in the memory 301 to implement the steps in any of the above-mentioned methods for repairing the server without password mutual trust. In a specific implementation scenario, the electronic device 300 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 300 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0106] Specifically, the processor 302 is used to control itself and the memory 301 to implement the steps in any of the above-mentioned methods for repairing the server without secret mutual trust. The processor 302 can also be called a CPU (Central Processing Unit). The processor 302 may be an integrated circuit chip with signal processing capabilities. The processor 302 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 302 can be implemented by an integrated circuit chip.
[0107] In this exemplary electronic device, a node to be detected corresponding to a target node in a server cluster is obtained; a password-free connection process is performed between the target node and the node to be detected to obtain a password-free connection result, thereby being able to characterize whether a password-free connection can be normally performed between the target node and each node to be detected through the password-free connection result; in response to the password-free connection result characterizing that there is a node to be detected that fails to make a password-free connection, password verification information is sent to each node to be detected to perform password consistency verification, and it is determined whether the reason for the failure of the password-free connection is due to inconsistent passwords of each node; in response to the verification result fed back by each node to be detected characterizing that the passwords between the target node and each node to be detected are consistent, it is determined that the failure of the password-free connection may be caused by a problem with the configuration file of each node, and therefore, file repair processing is performed on the original configuration file in each node based on the preset target configuration file to obtain a repaired node; thereby achieving efficient detection of the problem of failed password-free connections between server nodes and rapid repair of password-free connections.
[0108] See also Figure 4 , Figure 4 The computer-readable storage medium 410 stores program instructions 411 that can be executed by a processor, and the program instructions 411 are used to implement the steps in any of the above-mentioned methods for repairing server mutual trust without password.
[0109] In this exemplary storage medium, the node to be detected corresponding to the target node in the server cluster is obtained by running the program instructions in the storage medium; a password-free connection process is performed between the target node and the node to be detected to obtain a password-free connection result, thereby being able to characterize whether the target node and each node to be detected can normally perform a password-free connection through the password-free connection result; in response to the password-free connection result characterizing that there is a node to be detected that fails to make a password-free connection, password verification information is sent to each node to be detected for password consistency verification to determine whether the reason for the failure of the password-free connection is due to inconsistent passwords of each node; in response to the verification result fed back by each node to be detected characterizing that the passwords between the target node and each node to be detected are consistent, it is determined that the failure of the password-free connection may be caused by a problem with the configuration file of each node, and therefore, the original configuration file in each node is repaired based on the preset target configuration file to obtain a repaired node; thereby achieving efficient detection of the problem of failed password-free connections between server nodes and rapid repair of password-free connections.
[0110] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0111] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0112] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0113] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
Claims
1. A method for repairing server mutual trust without password, characterized in that: The method is applied to a target node in a server cluster, and the method comprises: Obtaining a node to be detected corresponding to the target node in the server cluster; Performing a secret-free connection process between the target node and the node to be detected to obtain a secret-free connection result; In response to the password-free connection result indicating that there is a node to be detected that has failed the password-free connection, sending password verification information to each node to be detected for password consistency verification; In response to the verification results fed back by the nodes to be detected indicating that the passwords between the target node and the nodes to be detected are consistent, it is determined that there is a configuration file problem in the password-free connection, and the original configuration files in each node are repaired based on the preset target configuration file to obtain a repaired node; The target configuration file includes an environment configuration file and an encryption protocol installation package. The step of performing file repair processing on the original configuration file in each node based on the preset target configuration file to obtain the repaired node includes: in response to the encryption protocol installation package being compatible with each node, replacing the original configuration file in each node according to the environment configuration file to obtain the repaired node; In response to the verification results fed back by the nodes to be detected indicating that the passwords between the target node and the nodes to be detected are inconsistent, it is determined that there is a password problem in the password-free connection, and the repair is suspended or stopped.
2. The method according to claim 1, characterized in that The method of performing file repair processing on the original configuration file in each node based on the preset target configuration file to obtain a repaired node includes: Performing file repair processing on the original configuration file in the target node based on the target configuration file to obtain a repaired target node; The target configuration file is sent to each node to be detected, so that each node to be detected performs file repair processing on the original configuration file in the corresponding node based on the received target configuration file to obtain each node to be detected after repair.
3. The method according to claim 2, characterized in that The performing file repair processing on the original configuration file in the target node based on the target configuration file to obtain a repaired target node includes: Replacing the original configuration file in the target node with the target configuration file to obtain the replaced file in the target node; Detecting whether the replaced file in the target node is compatible with the target node; If compatible, the replaced file is loaded into the target node to obtain the repaired target node.
4. The method according to claim 3, characterized in that The step of replacing the original configuration file in the target node with the target configuration file to obtain the replaced file in the target node includes: Backing up the original configuration file in the target node to obtain a backup configuration file; Replace the original configuration file in the target node based on the target configuration file to obtain a replaced file in the target node; After detecting whether the replaced file in the target node is compatible with the target node, the method further includes: if not compatible, performing a restoration process using a backup configuration file corresponding to the target node.
5. The method according to claim 3, characterized in that: The target configuration file includes an encryption protocol installation package, and the detecting whether the replaced file in the target node is compatible with the target node includes: Obtaining version information of the encryption protocol installation package; Determining whether the encryption protocol installation package is compatible with the target node based on version information of the encryption protocol installation package; After detecting whether the replaced file in the target node is compatible with the target node, the method further includes: in response to the encryption protocol installation package being compatible with the target node, installing the encryption protocol installation package on the target node.
6. The method according to claim 1, characterized in that The password verification information includes a server password, and in response to the password-free connection result indicating that there is a node to be detected that fails the password-free connection, the password verification information is sent to each node to be detected for password consistency verification, including: Performing password authentication connection on each node to be detected based on the server password; If the connection with each node to be detected is successful, it indicates that the passwords between the target node and each node to be detected are consistent; If there is a node with failed connection among the nodes to be detected, it indicates that the passwords of the nodes are inconsistent, the node with failed connection is fed back, and the repair is paused or stopped.
7. The method according to claim 1, characterized in that The obtaining the node to be detected corresponding to the target node in the server cluster includes: Obtaining each initial node corresponding to a preset node type in the server cluster; Merging and deduplicating the node addresses of the initial nodes corresponding to the preset node type to obtain processed node addresses; The node corresponding to the processed node address is determined as the node to be detected.
8. The method according to claim 1, characterized in that Before performing file repair processing on the original configuration file in each node based on the preset target configuration file to obtain the repaired node, the method further includes: Extracting quantity information and text description information of the target configuration file; Performing file verification processing on the target configuration file based on the quantity information and the text description information to obtain a file verification result; If the file verification result indicates that the target configuration file meets the preset file standard, a file repair process is performed based on the target configuration file.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 8.
10. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
