Method and system for training and pushing container SSH service user password persistence based on AI large model
By implementing SSH password persistence tools and startup scripts in Docker containers, the problem of SSH password loss after container restart is solved, management efficiency and security are improved, and SSH configuration automation and consistency management is realized.
Patent Information
- Application Number
- CN202411602736.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-04-04
AI Technical Summary
After the Docker container is restarted or rebuilt, the SSH service user password is lost, causing the administrator to be unable to reconnect. Manual password setting poses security risks and management complexity.
Implement the SSH password persistence tool through C language, and use the Shell language to implement container startup and running scripts. The persistence tool and script programs are stored in the Dockerfile compilation environment. It is copied into the image during compilation, and the SSH configuration is loaded from the persistent volume when the container is started.
It realizes the persistence of SSH service user passwords in Docker containers, avoids the tedious operation and security risks of manually setting passwords, and improves the efficiency and consistency of container management.
Smart Images

Figure CN119759483A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data persistence, and in particular to a method and system for persisting container SSH service user passwords based on AI large model training. Background Art
[0002] Docker container technology is a lightweight virtualization technology that can run multiple independent applications or services on an operating system. SSH service is a secure remote login protocol that allows users to connect to the SSH server on a remote server through an SSH client on a local computer to perform tasks such as command line operations and file transfers. Traditional Docker container management relies on SSH service for remote access and management. SSH service configuration includes user accounts and passwords, which are stored in the file system inside the container. However, the file system of the Docker container is transient, which means that when the container is restarted or rebuilt, all non-persistent data will be lost, including the SSH configuration. Docker container technology is:
[0003] 1. In traditional Docker container management, the SSH service is used to remotely manage and control the container environment.
[0004] 2. SSH service usually requires setting up a user and password for authentication.
[0005] 3. The configuration within the container (including SSH passwords) is usually stored in the container's file system.
[0006] 4. When the container is restarted or rebuilt, the original configuration information will be lost due to the transient nature of the file system.
[0007] Traditional solutions usually require manual setting of user passwords for SSH services in Docker containers, and the passwords will be lost after the container is restarted. This brings inconvenience to users, who need to reset their passwords before they can use the SSH service again. In addition, manually setting passwords also poses certain security risks and can be easily exploited by attackers. There are the following technical defects:
[0008] 1. Configuration loss: After the container is restarted or rebuilt, the original SSH configuration cannot be restored, resulting in the administrator being unable to reconnect via SSH.
[0009] 2. Security risk: In order to avoid reconfiguring SSH every time you start it, the SSH password is hard-coded in the Dockerfile in some scenarios. e or startup scripts, which is highly vulnerable to leaks.
[0010] 3. Inefficiency: Manually configuring the SSH service for each container is time-consuming and error-prone, especially in large deployments.
[0011] 4. Inconsistency: The lack of a unified management method may lead to inconsistent SSH configurations between different containers, increasing management complexity. Summary of the invention
[0012] The purpose of this invention is to provide a safe, reliable and automatic SSH password persistence mechanism to ensure that D oc After the Docker container is restarted or rebuilt, the SSH service user password is still valid, while eliminating the security risks caused by hard coding, improving the efficiency and consistency of container management, and achieving the following goals: 1. Provide a method to ensure that the SSH service user password in the Docker container is still available after the container is restarted or rebuilt. 2. Implement secure storage and automatic loading of SSH passwords to avoid problems caused by manual configuration and hard coding. 3. Achieve consistency of SSH configuration between containers, facilitating large-scale deployment and management.
[0013] In order to solve the above technical problems, the present invention provides a method for persisting user passwords of container SSH service based on AI large model training, comprising the following steps:
[0014] Implement SSH password persistence tool through C language;
[0015] Use Shell language to start and run script programs in containers;
[0016] Store the SSH password persistence tool and container startup script program in the Dockerile compilation environment working directory;
[0017] When writing the Dockerfle script and compiling it, the SSH password persistence tool and the container startup script program in the working directory are copied to the image to generate the image;
[0018] Push the compiled image docker push to harbor image repository for persistent storage;
[0019] Use the docker pu command on the kubernetes cluster management node or the docker host operating environment to pull the image;
[0020] Set the running parameters when the container starts;
[0021] The container starts and runs to provide SSH remote access services to the outside world. The default password is used for the first login. The password in the persistent volume is loaded when the container is restarted.
[0022] The client enters the username and password to log in, remotely executes SSH and SFTP commands, and remotely changes the user login password.
[0023] Preferably, the SSH password persistence tool is implemented by C language, specifically including the following steps:
[0024] Generate the initial password for the login account;
[0025] Encrypt the initialization password to obtain the encrypted password;
[0026] Persist the encrypted password to the file system;
[0027] Load the password file and import the password file into the system;
[0028] Compile the system source code to generate the SSH password persistence tool.
[0029] Preferably, the SSH password persistence tool and the container startup script are stored in the Dockerile compilation environment working directory, specifically including the following steps:
[0030] Use the apt-get command to update the package index and install the initial packages; the initial packages include the vim editor, openSSH-server, network tools such as net-tools, iproute2, inetutils-ping, telnet, netcat, and nano;
[0031] Copy the run.sh script that runs when the custom container starts and the SSH encryption service user password persistence tool bin program SSHpasswd to the / usr / run.sh and / usr / local / bin / SSHpasswd locations in the container respectively.
[0032] Preferably, when compiling the Dockerfle script, the SSH password persistence tool and the container startup script program in the working directory are copied into the image to generate an image, which specifically includes the following steps:
[0033] Update the package list and install additional packages, including perl, git, curl, and sudo; install Python packages through pip, including nbclassic, jupyterlab, and jupyterlab-git; unzip the node12.tgz archive file to / usr / local, clean the user cache, create a data directory / data, add user groups and users, and set the corresponding permissions and ownership;
[0034] Configure the basic parameters of the SSH service, create the running directory / var / run / SSHd, set the root user password, enable root login, and change the location of the authorized key file; create the start, stop, and restart scripts for the SSH service and grant execution permissions;
[0035] Expose the standard SSH port 22, as well as custom ports 2022, 8085, and 8181; set the container’s entry point to the run.sh script.
[0036] Preferably, the operating parameters when the container is started are: number of CPU cores + number of GPU graphics cards + memory size + persistent volume size.
[0037] Preferably, the specific implementation of the startup script run.sh in the container includes application deployment and verification, SSH service configuration and password management, environment variables and SSH service startup.
[0038] Preferably, application deployment and verification specifically include the following steps:
[0039] Check whether the application exists: The script first checks whether the main.py file in the target directory / data / .app exists. If it does, the output information indicates that the application has been deployed.
[0040] Version acquisition and download: If main.py does not exist, extract the version information from the input parameters and use the curl command to download the corresponding version of the application compressed package to the temporary file / tmp / app.tar.gz;
[0041] Integrity check: After the download is complete, use the sha1sum tool to check the SHA1 hash value of the file to ensure that the file has not been tampered with or damaged during the transmission process; if the check fails, an error message is output and the script execution is exited;
[0042] Decompression and cleaning: After verification, create the application directory / data / .app, decompress the application package to this directory, and delete temporary files;
[0043] Preferably, SSH service configuration and password management specifically include the following steps:
[0044] Password file check: Check whether the password file / data / .ssh / sshsrv-password.txt of the SSH service exists. If it exists, output the information and call the sshpasswd tool to load the password file;
[0045] Password file creation: If the password file does not exist, create a log and SSH directory, use the sshpasswd tool to generate a default password and save it to sshsrv-password.txt, and copy the sshpasswd tool to the .ssh directory for subsequent operations.
[0046] Preferably, the environment variables and SSH service startup specifically include the following steps:
[0047] Environment variable update: modify the user's .bashrc file and add a new PATH environment variable to ensure the executableness of the tools required by the application and SSH service;
[0048] Start the SSH service in the background: Use the nohup command to start the SSH service startup script ssh_start.sh in the background, redirect the standard output and error output to / dev / null, and ensure that the service can continue to run after the script exits;
[0049] Start the main application program: Finally, use the python3 command to execute the main application program main.py to ensure that the application service and the SSH service run synchronously.
[0050] The present invention also provides a container SSH service user password persistence system based on AI large model training, including:
[0051] Tool compilation module, used to implement SSH password persistence tool in C language;
[0052] The script program startup and running module is used to start and run the script program in the container through the Shell language;
[0053] Storage module, used to store SSH password persistence tool and container startup script program in the working directory of Dockerile compilation environment;
[0054] The image generation module is used to write the Dockerfle script to generate an image by copying the SSH password persistence tool and the container startup script program in the working directory.
[0055] The persistent storage module is used to push the compiled image docker push to the harbor image repository for persistent storage;
[0056] Image pulling module, used for Kubernetes cluster management nodes or Docker host running environment docker pu command to pull images;
[0057] The running parameter setting module is used to set the running parameters when the container is started;
[0058] SSH remote access service module, used to provide SSH remote access service to the outside world when the container is started and running, with the default password for the first login and the password in the persistent volume loaded when the container is restarted;
[0059] The login module is used by the client to enter the username and password to log in, remotely execute SSH and SFTP commands, and remotely modify the user login password.
[0060] Compared with the prior art, the present invention has the following beneficial effects:
[0061] 1. Implement persistence of the SSH service user password in the Docker container; solve the problem of manually setting the password every time the container is restarted. The SSH configuration is persistently stored and the service is immediately available after the container is restarted.
[0062] 2. Improve user experience and reduce the tedious operation of manually setting passwords; automatic configuration loading reduces manual intervention and reduces error rate.
[0063] 3. Enhanced security, avoiding the security risks that may exist when setting passwords manually; passwords are encrypted and stored to prevent unauthorized access.
[0064] 4. Simplify access control of multi-container clusters and ensure unified SSH configuration management with consistency. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The specific implementation modes of the present invention are further described in detail below with reference to the accompanying drawings.
[0066] Figure 1 The present invention is a flowchart of a method for training and promoting user password persistence of container SSH service based on a large AI model. DETAILED DESCRIPTION
[0067] Many specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited to the specific implementation disclosed below.
[0068] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0069] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0070] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0071] The present invention provides a method for persisting user passwords of container SSH services based on AI large model training. Figure 1 As shown, the following steps are included:
[0072] Use C language to design and implement the SSH password persistence tool, and use Shell language to implement the container startup script program. Each time the container starts, re-import the password in the persistent volume and use the default password for the first login. The password in the persistent volume is loaded when the container is restarted. When the Dockerfile script is compiled, the startup script + SSH password persistence tool in the working directory is copied into the image to generate an image, and the SSH configuration is loaded from the persistent storage when the container starts. Custom or key management services (such as Vault, Kubernetes Secrets) can be used to encrypt and store SSH passwords, and the K8S cluster and Docker environment can be used to start and run the container to provide an SSH password persistence service method. This method can be integrated into the CI / CD process while ensuring data security, and realize automatic update and management of SSH service user password configuration.
[0073] The specific design implementation process is:
[0074] 1. Use C language to implement SSH password persistence tool.
[0075] 1.1 The login account initialization password is randomly generated.
[0076] (1) Define a character set that contains uppercase and lowercase letters and numbers, such as lowercase letters 'a' to 'z', uppercase letters 'A' to 'Z', and numbers '0' to '9'. This character set is used to generate each character in the password.
[0077] (2) Enter the loop process, and the number of iterations is equal to the length of the password to be generated. In each loop, a character is randomly selected from the above character set and added to the password string being constructed. A random number generation function is used here to ensure that the selection of each character is unpredictable.
[0078] (3) After the password of the specified length is generated, a null character ('\0') is added to the end of the password string to mark the end of the string, thus forming a complete random password.
[0079] This method can ensure that the generated password is highly random and secure, and is suitable for fields where encryption key security is sensitive.
[0080] 1.2 Encrypt the randomly generated password.
[0081] (1) Create a file stream (FILE*) variable fp for subsequent pipe operations. Next, initialize a character array cmd and prefill it with part of the command line instruction to call the external encryption program "openssl", which is used to perform MD5-based Unix password encryption (identifier '-1').
[0082] (2) Append the original password string to be encrypted to cmd to form a complete command line string so that the openssl tool can be called to encrypt it.
[0083] (3) After confirming that the pipe is successfully opened through the popen function, start reading the output generated by the openssl tool. In order to receive and store the encrypted password, a buffer buf is used, and the pipe output is read line by line through the fgets function until the end of the file (EOF) is encountered. Each line of output is appended to the encrypted_password character array, which is used to finally store the encrypted password.
[0084] (4) When all outputs have been read, the pipe is closed through the pclose function to release related resources. Finally, the method returns a status code of 0, indicating that the encryption process has been successfully completed.
[0085] The present invention allows the security of passwords to be enhanced by calling powerful external encryption tools without implementing complex encryption algorithms within the application program, which not only simplifies the development process but also improves the reliability of password protection.
[0086] 1.3 The encrypted password is persisted to the file system.
[0087] (1) Define a file pointer file to point to the target file to be written. By calling the fopen function, try to open the specified file in write mode ("w"), where the file name is provided by the parameter filename.
[0088] (2) If the file fails to be opened successfully, that is, the fopen function returns NULL, it is determined that the file path or file name is invalid. At this time, an error message will be output to the user, prompting the user to check whether the file path and name are correct, and an error code of -1 will be returned. On the contrary, if the file is successfully opened, the program will execute the fputs function to write the encrypted password information passed by the filecontent parameter to the opened file. After the writing operation is completed, the fclose function is immediately called to close the file to ensure that the data is correctly saved to the disk.
[0089] (3) Output a message to inform the user that the file write operation has been completed, and display the written file name and file content for verification. This method returns a status code of 0, indicating that the file save operation was successful.
[0090] This method ensures that the encrypted password can be reliably stored in the file system, providing basic support for subsequent password management operations. It is suitable for any application scenario that requires persistent storage of sensitive information.
[0091] 1.4 Load the password file and import the password into the system.
[0092] (1) Declare a file pointer fp for subsequent pipeline operations. Then, initialize a character array cmd, which is pre-filled with some command line instructions to call the chpasswd command, which is a utility for batch changing passwords. The --encrypted option is specially specified here, indicating that the input password is already in encrypted format.
[0093] (2) The file name containing the encrypted password is appended to cmd through the strcat function so that the complete command can read the file as an input source. In this way, a complete command is constructed to load the encrypted password from the specified file into the system.
[0094] (3) After confirming that the pipe has been successfully created through the popen function, that is, fp is not NULL, the program will execute the command to read the encrypted password information from the file and automatically apply it to the system's password database to complete the password update operation. If an error occurs when opening the pipe, that is, the popen function returns NULL, an error message will be output to indicate that the pipe opening failed, and the program execution will be terminated through the exit(1) function to ensure that the abnormal situation is properly handled. Once the password update operation is completed, whether successful or not, the previously opened pipe will be closed through the pclose function to release related resources. Subsequently, a message will be output to display the file name and confirm that the password change operation has been successfully executed.
[0095] (4) This method returns status code 0, indicating that the password loading and updating operations are completed normally, ensuring the automation and security of the system password management process.
[0096] This method is suitable for various scenarios where system passwords need to be updated regularly or on demand, especially in environments with high security requirements, such as SSH server management, network security configuration, etc.
[0097] 2. Compile and generate the container image through the Dockerfile script to install and build the SSH server, SSH password persistence tool, software dependencies and operating environment in the container.
[0098] (1) Base image selection: Start building from a predefined base image, which is specifically used to run the SSH service container image.
[0099] (2) Package installation: Use the apt-get command to update the package index and install a series of necessary packages, including the vim editor, openssh-server (for SSH service), network tools such as net-tools, iproute2, inetutils-ping, telnet, netcat, and nano. Afterwards, clean up the cache directory to save space.
[0100] (3) Copying custom scripts: Copy the run.sh script that runs when the custom container starts and the SSH encryption service user password persistence tool bin program sshpasswd to the / usr / run.sh and / usr / local / bin / sshpasswd locations in the container respectively. sshpasswd may be a custom tool for password management.
[0101] (4) Runtime environment construction: further update the package list, install additional packages such as perl, git, curl, and sudo, allow unsigned package installation, avoid recommended package installation, and allow downgrade installation. Install specific versions of Python packages such as nbclassic, jupyterlab, and jupyterlab-git through pip. In addition, unzip the node12.tgz archive file to / usr / local, clean the user cache, create the data directory / data, add user groups and users, and set the corresponding permissions and ownership.
[0102] (5) SSH service configuration: Configure the basic parameters of the SSH service, including creating the running directory / var / run / sshd, setting the root user password (for example: abcd1234), enabling root login, and changing the location of the authorized key file. In addition, create the start, stop, and restart scripts for the SSH service and grant execution permissions.
[0103] (6) Port exposure and entry point setting: Expose the standard SSH port 22, as well as custom ports 2022, 8085, and 8181. Set the container's entry point to the run.sh script so that predefined tasks are automatically executed when the container starts.
[0104] This method aims to automatically build a container image that includes SSH service and password management functions, which can be widely used in cloud environments, server clusters and other scenarios that require remote access and secure password management.
[0105] 3. Use the K8S cluster and Docker environment to start running containers to provide SSH password persistence service methods.
[0106] 3.1 Run the docker pull command on the kubernetes cluster management node or docker host running environment to pull the image. Before starting the container, configure the running parameters when the container starts: number of CPU cores + number of GPU graphics cards + memory size + persistent volume size, etc.
[0107] 3.2 When the container starts, the SSH password persistence tool reads the file containing the user password and updates the SSH password to the system password file. After the container starts, it provides SSH remote access services to the outside world and uses the default password for the first login. The password in the persistent volume is loaded when the container is restarted.
[0108] 3.3 The client enters the username and password to log in, and can remotely execute SSH and SFTP commands to remotely modify the user login password. The modified password will be saved to the specified path of the container mounted persistent volume. Even if the container is restarted, the use of the password will not be affected.
[0109] Specific implementation of the startup script run.sh in the container:
[0110] (1) Application deployment and verification:
[0111] Check whether the application exists: The script first checks whether the main.py file in the target directory / data / .app exists. If it does, the output information indicates that the application has been deployed.
[0112] Version acquisition and download: If main.py does not exist, extract the version information from the input parameters and use the curl command to download the corresponding version of the application compressed package to the temporary file / tmp / app.tar.gz.
[0113] Integrity check: After the download is complete, use the sha1sum tool to check the SHA1 hash value of the file to ensure that the file has not been tampered with or damaged during the transmission process. If the check fails, an error message is output and the script execution is exited.
[0114] Decompression and cleaning: After verification, create the application directory / data / .app, decompress the application package to this directory, and delete temporary files.
[0115] (2) SSH service configuration and password management
[0116] Password file check: Check whether the password file / data / .ssh / sshsrv-password.txt of the SSH service exists. If it exists, output information and call the sshpasswd tool to load the password file.
[0117] Password file creation: If the password file does not exist, create a log and SSH directory, use the sshpasswd tool to generate a default password and save it to sshsrv-password.txt, and copy the sshpasswd tool to the .ssh directory for subsequent operations.
[0118] (3) Environment variables and SSH service startup
[0119] Update environment variables: Modify the user's .bashrc file and add a new PATH environment variable to ensure the executableness of the tools required by the application and SSH service.
[0120] Start the SSH service in the background: Use the nohup command to start the SSH service startup script ssh_start.sh in the background, redirect the standard output and error output to / dev / null, and ensure that the service can continue to run after the script exits.
[0121] Start the main application program: Finally, use the python3 command to execute the main application program main.py to ensure that the application service and the SSH service run synchronously.
[0122] The present invention provides an automated, efficient and secure deployment and maintenance mechanism, which is suitable for automated management of remote servers, and performs well in scenarios where frequent application updates and SSH service stability need to be ensured.
[0123] The present invention mainly provides the following key points:
[0124] 1. Use C language to implement SSH password initialization random generation, encryption method, persistence and password import tool method.
[0125] 2. Compile and generate the container image through the Dockerfile script to implement the installation and construction method of the SSH server, SSH password persistence tool, software dependencies and operating environment in the container.
[0126] 3. Use the K8S cluster and Docker environment to start running containers to provide SSH password persistence services.
[0127] In order to better illustrate the technical effect of the present invention, the present invention provides the following specific embodiments to illustrate the above technical process:
[0128] Embodiment 1: A method for persisting user passwords of container SSH services based on AI large model training. Figure 1 As shown, the following steps are included:
[0129] 1. Compile password persistence tool (implemented in C language)
[0130] 1.1 The login account initialization password is randomly generated.
[0131] 1.2 Encrypt the randomly generated password.
[0132] 1.3 The encrypted password is persisted to the file system.
[0133] 1.4 Load the password file and import the password into the system.
[0134] 1.5 Compile the source code to generate the ssh service password persistence program.
[0135] 2. Compile the base image (Dockerfile)
[0136] 2.1 Write the entry program to run when the container starts.
[0137] 2.2 Write the Dockerfile file to package the ssh service password persistence program, run.sh entry script program, software dependencies, and system tools into the container image.
[0138] Install software packages, build the main program running environment, and configure default SSH service parameters;
[0139] 2.3 Compile the Dockerfile file to generate the container-dependent base image.
[0140] 3. Docker environment running image
[0141] 4. Enter the Docker container, docker exec-it+image name bash
[0142] 5. Start the SSH service command in the container
[0143] 6. Modify the SSH user password in the container (default: root)
[0144] 7. Original method of modifying user password in container
[0145] 8. Save the verified available basic image as a compressed package
[0146] 9. Push the basic image to the DockerHarbor private service warehouse. The K8S cluster directly accesses the Harbor warehouse to obtain the image and starts the container to provide SSH password persistence service to the outside world.
[0147] 10. Through the SSH client user account and password, you can log in to the SSH container normally to execute commands, or perform sftp file upload and download operations on the client. The normal use of SSH service will not be affected after the container is restarted.
[0148] ssh root@172.xx.xxx.76-p 8022##password screencast
[0149] sftp-P 8022root@172.xx.xxx.76##password screencast
[0150] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules, modules or units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units, modules or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0151] The units may or may not be physically separated, and the components displayed as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0152] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0153] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part, and / or installed from a removable medium. When the computer program is executed by the central processing unit (CPU), the above-mentioned functions defined in the method of the present invention are executed. It should be noted that the above-mentioned computer-readable medium of the present invention can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of an electrical, magnetic, optical, electromagnetic, infrared segment, or semiconductor, or any combination of the above.
[0154] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0155] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for persisting user passwords for container SSH services based on AI big model training, characterized in that: The following steps are involved: Implement SSH password persistence tool through C language; Use Shell language to start and run script programs in containers; Store the SSH password persistence tool and container startup script program in the Dockerile compilation environment working directory; When writing the Dockerfle script and compiling it, the SSH password persistence tool and the container startup script program in the working directory are copied to the image to generate the image; Push the compiled image docker push to harbor image repository for persistent storage; Use the docker pu command on the kubernetes cluster management node or the docker host operating environment to pull the image; Set the running parameters when the container starts; The container starts and runs to provide SSH remote access services to the outside world. The default password is used for the first login. The password in the persistent volume is loaded when the container is restarted. The client enters the username and password to log in, remotely executes SSH and SFTP commands, and remotely changes the user login password.
2. According to the AI large model training and promotion container SSH service user password persistence method according to claim 1, it is characterized in that: Implementing the SSH password persistence tool using C language includes the following steps: Generate the initial password for the login account; Encrypt the initialization password to obtain the encrypted password; Persist the encrypted password to the file system; Load the password file and import the password file into the system; Compile the system source code to generate the SSH password persistence tool.
3. According to the AI large model training and promotion container SSH service user password persistence method according to claim 2, it is characterized in that: Store the SSH password persistence tool and container startup script program in the Dockerile compilation environment working directory. The specific steps include: Use the apt-get command to update the package index and install the initial packages; the initial packages include the vim editor, openSSH-server, network tools such as net-tools, iproute2, inetutils-ping, telnet, netcat, and nano; Copy the run.sh script that runs when the custom container starts and the SSH encryption service user password persistence tool bin program SSHpasswd to the / usr / run.sh and / usr / local / bin / SSHpasswd locations in the container respectively.
4. According to the AI large model training and promotion container SSH service user password persistence method according to claim 3, it is characterized in that: When writing the Dockerfle script, compile the SSH password persistence tool and the container startup script program in the working directory to copy the image to generate the image. The specific steps include: Update the package list and install additional packages, including perl, git, curl, and sudo; install Python packages through pip, including nbclassic, jupyterlab, and jupyterlab-git; unzip the node12.tgz archive file to / usr / local, clean the user cache, create a data directory / data, add user groups and users, and set the corresponding permissions and ownership; Configure the basic parameters of the SSH service, create the running directory / var / run / SSHd, set the root user password, enable root login, and change the location of the authorized key file; create the start, stop, and restart scripts for the SSH service and grant execution permissions; Expose the standard SSH port 22, as well as custom ports 2022, 8085, and 8181; set the container’s entry point to the run.sh script.
5. According to the AI large model training and promotion container SSH service user password persistence method according to claim 4, it is characterized in that: The running parameters when the container is started are: number of CPU cores + number of GPU graphics cards + memory size + persistent volume size.
6. According to the AI large model training and promotion container SSH service user password persistence method according to claim 5, it is characterized by: The specific implementation of the startup script run.sh in the container includes application deployment and verification, SSH service configuration and password management, environment variables and SSH service startup.
7. According to the AI large model training and promotion container SSH service user password persistence method according to claim 6, it is characterized in that: Application deployment and verification, including the following steps: Check whether the application exists: The script first checks whether the main.py file in the target directory / data / .app exists. If it does, the output information indicates that the application has been deployed. Version acquisition and download: If main.py does not exist, extract the version information from the input parameters and use the curl command to download the corresponding version of the application compressed package to the temporary file / tmp / app.tar.gz; Integrity check: After the download is complete, use the sha1sum tool to check the SHA1 hash value of the file to ensure that the file has not been tampered with or damaged during the transmission process; if the check fails, an error message is output and the script execution is exited; Decompression and cleaning: After verification, create the application directory / data / .app, decompress the application package to this directory, and delete temporary files.
8. According to the AI large model training and promotion container SSH service user password persistence method according to claim 7, it is characterized in that: SSH service configuration and password management include the following steps: Password file check: Check whether the password file / data / .ssh / sshsrv-password.txt of the SSH service exists. If it exists, output the information and call the sshpasswd tool to load the password file; Password file creation: If the password file does not exist, create a log and SSH directory, use the sshpasswd tool to generate a default password and save it to sshsrv-password.txt, and copy the sshpasswd tool to the .ssh directory for subsequent operations.
9. The method for persisting container SSH service user password based on AI large model training according to claim 8 is characterized in that: Environment variables and SSH service startup include the following steps: Environment variable update: modify the user's .bashrc file and add a new PATH environment variable to ensure the executableness of the tools required by the application and SSH service; Start the SSH service in the background: Use the nohup command to start the SSH service startup script ssh_start.sh in the background, redirect the standard output and error output to / dev / null, and ensure that the service can continue to run after the script exits; Start the main application program: Finally, use the python3 command to execute the main application program main.py to ensure that the application service and the SSH service run synchronously.
10. A system for training and pushing container SSH service user password persistence based on AI large model, used to implement the method for training and pushing container SSH service user password persistence based on AI large model as described in any one of claims 1-9, characterized in that: include: Tool compilation module, used to implement SSH password persistence tool in C language; The script program startup and running module is used to start and run the script program in the container through the Shell language; Storage module, used to store SSH password persistence tool and container startup script program in the working directory of Dockerile compilation environment; The image generation module is used to write the Dockerfle script to generate an image by copying the SSH password persistence tool and the container startup script program in the working directory. The persistent storage module is used to push the compiled image docker push to the harbor image repository for persistent storage; Image pulling module, used for Kubernetes cluster management nodes or Docker host running environment docker pu command to pull images; The running parameter setting module is used to set the running parameters when the container is started; SSH remote access service module, used to provide SSH remote access service to the outside world when the container is started and running, with the default password for the first login and the password in the persistent volume loaded when the container is restarted; The login module is used by the client to enter the username and password to log in, remotely execute SSH and SFTP commands, and remotely modify the user login password.