A remote shell command execution control method, system and storage medium

CN122547573APending Publication Date: 2026-08-11ZHENGZHOU WEITONG TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-22
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0002]传统远程shell命令执行技术在实际应用中存在多重安全与可靠性缺陷,难以适配复杂场景下的系统防护需求

Benefits of technology

[0039] This invention uses a side effect classification mechanism to identify commands with different risk levels and generate commands that can be executed, require confirmation before execution, or are prohibited from execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122547573A_ABST
    Figure CN122547573A_ABST
Patent Text Reader

Abstract

This invention discloses a method, system, and storage medium for controlling the execution of remote shell commands, relating to the field of remote shell technology. The key technical points include the following steps: obtaining a shell command string to be executed; classifying the shell command string for side effects to obtain an execution decision including allowing execution, requiring confirmation before execution, or prohibiting execution; if the execution decision is to prohibit execution, terminating automatic execution and outputting security boot information; if the execution decision is to require confirmation before execution, executing only after receiving confirmation; the sub-command sequence includes at least some or all of the following: pre-write preview or change preview, pre-write backup, and post-write verification; controlling the execution of commands or steps in a remote terminal session based on the execution decision, sub-command sequence, and / or security boot information to improve the security, reliability, and auditability of remote shell command execution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of remote shell technology, and more specifically, to a method, system, and storage medium for controlling the execution of remote shell commands. Background Technology

[0002] Traditional remote shell command execution technology has multiple security and reliability flaws in practical applications, making it difficult to adapt to the system protection needs in complex scenarios.

[0003] First, traditional solutions lack a pre-emptive risk identification mechanism for shell commands and cannot classify and control the side effects of commands. High-risk commands such as downloading and pipe-executing remote scripts and performing destructive file operations can be executed directly on remote terminals, which can easily lead to serious security incidents such as malicious code injection and irreversible damage to system files. Moreover, once such operations are executed, they cannot be rolled back, posing a great threat to system stability.

[0004] Secondly, for shell commands that write files, traditional execution methods do not have a reliability guarantee process. Write commands such as heredoc syntax often fail to write files and cause data corruption due to problems such as incomplete termination markers and abnormal content. Furthermore, there is a lack of backup before writing and verification after writing. Once an error occurs, data cannot be recovered quickly, which can easily cause business interruption or data loss.

[0005] Meanwhile, in scenarios where AI agents invoke remote shell tools, the commands generated by AI may contain logical defects, syntax errors, or high-risk instructions. Traditional execution methods cannot effectively verify and control such commands, and direct execution may lead to unexpected system operations, amplifying security and operational risks.

[0006] Furthermore, traditional solutions fail to consider users' actual operational needs and lack pathways to guide users towards safe alternative operations, impacting user experience and work efficiency. Therefore, existing remote shell command execution technologies suffer from issues such as inadequate risk control, insufficient reliability, and poor scenario adaptability. Summary of the Invention

[0007] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a method, system and storage medium for controlling the execution of remote shell commands.

[0008] To achieve the above objectives, the present invention provides the following technical solution:

[0009] A method for controlling the execution of remote shell commands, comprising the following steps:

[0010] Retrieve the shell command string to be executed;

[0011] The shell command string is categorized for side effects to obtain the corresponding execution decision; wherein the execution decision includes one of allowing execution, requiring confirmation before execution, or prohibiting execution.

[0012] If the execution decision is to prohibit execution, the automatic execution process of the shell command string is terminated, and security boot information related to the command is output.

[0013] If the decision to execute requires confirmation, then upon receiving the confirmation instruction, the shell command string and / or the converted subcommand sequence will be executed in the remote terminal session.

[0014] If the shell command string is identified as belonging to a preset file write command type, then according to the preset reliable execution protocol, the shell command string is converted into a sequence of subcommands to be executed sequentially on the remote end; wherein, the subcommand sequence includes steps for previewing the content to be written or changes, and backing up the target file before executing the write;

[0015] In a remote terminal session, the execution of corresponding commands or steps is controlled based on execution decisions, subcommand sequences, and / or security boot information.

[0016] Preferably, the shell command strings are categorized for side effects, including:

[0017] The features of the extracted shell command string are matched with a preset rule set to obtain the matching result; wherein, the preset rule set corresponds to different side effect categories;

[0018] The set of side effect categories for the shell command string is determined based on the matching results, and an execution decision is generated based on the set of side effect categories and the preset decision strategy.

[0019] Preferably, the preset rule set includes a strong blocking rule set and a confirmation rule set;

[0020] When the shell command string matches the set of strong blocking rules, the generated execution decision is to prohibit execution;

[0021] When the shell command string matches the rule set that requires confirmation, the generated execution decision is to execute after confirmation.

[0022] Preferably, the command patterns used for matching in the strong blocking rule set include:

[0023] This includes commands that connect download tools to a shell interpreter via a pipe, as well as commands that contain extremely high-risk file system corruption operation modes.

[0024] Preferably, the secure boot information includes: when the shell command string is a command to download and pipe-execute a remote script, generating an executable task plan for bootstrapping secure operations; the executable task plan specifically includes the following steps:

[0025] When the shell command string is a command to download and pipe a remote script, resolve the remote address of the script;

[0026] The script content from the remote address is downloaded to a preset cache path in the remote terminal session, the script content is previewed, the script content is syntax checked, and prompts are output to guide the user to manually execute the script in the cache path.

[0027] Preferably, converting the shell command string into a sequence of subcommands executed sequentially on the remote end includes: when the shell command string is a command to create or write a file using heredoc syntax, checking whether the command's termination marker is completely closed; if it is not completely closed, blocking the write and outputting a prompt message; the subcommand sequence also includes a post-write verification step; the preset file write command type also includes a command to perform in-situ text replacement on the target file, and the subcommand sequence also includes a difference preview, a backup before writing, writing back to the target file via a temporary file, and a post-write verification step.

[0028] Preferably, the method further includes the following steps:

[0029] When receiving a tool invocation request from the AI ​​agent, extract the command string to be executed from the request;

[0030] The extracted command string undergoes side effect classification processing, and the execution decision controls whether the command string is executed in the remote terminal session.

[0031] A remote shell command execution control system, comprising:

[0032] The `get` module retrieves the shell command string to be executed.

[0033] Processing module: performs side effect classification on shell command strings to obtain the execution decision corresponding to the shell command string; wherein, the execution decision includes one of allowing execution, requiring confirmation before execution, and prohibiting execution;

[0034] Generation module: If the execution decision is to prohibit execution, the automatic execution process of the shell command string is terminated, and security guidance information related to the command is output; if the execution decision is to require confirmation before execution, the shell command string and / or the converted sub-command sequence are executed in the remote terminal session after receiving the confirmation instruction.

[0035] Conversion module: If the shell command string is identified as belonging to the preset file write command type, the shell command string is converted into a sequence of subcommands to be executed sequentially on the remote end according to the preset reliable execution protocol; wherein, the subcommand sequence includes steps for previewing the content to be written or changes, and backing up the target file before executing the write;

[0036] Control module: In a remote terminal session, it controls the execution of corresponding commands or steps based on execution decisions, sub-command sequences, and / or security boot information.

[0037] A storage medium storing a computer program that, when executed by a processor, implements a method for controlling the execution of remote shell commands.

[0038] Compared with the prior art, the present invention has the following beneficial effects:

[0039] This invention uses a side effect classification mechanism to identify commands with different risk levels and generate commands that can be executed, require confirmation before execution, or are prohibited from execution.

[0040] By intercepting high-risk commands at the source, including those that execute through download pipelines and perform extremely high-risk file corruption operations, malicious code can be prevented from being executed automatically or causing irreversible system damage, significantly improving the security protection capabilities of remote terminal sessions.

[0041] For downloading and pipelined execution of remote script commands, a safe operation task plan is used to break down high-risk operations into a step-by-step process in a remote terminal session, including downloading to a preset cache path, content preview, syntax checking, and guided manual execution. This preserves the user's operational needs while placing risks under human audit and control, thus balancing security and ease of use.

[0042] For file write commands, a preset reliability execution protocol transforms the original command into a sequence of sub-commands that includes content preview and target file backup steps. The backup operation before writing allows for rapid data recovery in case of write failure or inconsistent results. The preview step allows users to confirm the content to be written in advance, preventing file corruption and data loss due to command errors or logical flaws, significantly improving the reliability and rollbackability of file write operations. Remote terminal sessions implement scenario-based execution control based on execution decisions, sub-command sequences, or task plans, achieving hierarchical management of commands with different risk levels. This ensures efficient execution of legitimate commands while keeping high-risk and sensitive operations under control, forming a complete closed loop from risk identification and anomaly interception to secure execution, comprehensively improving the security, reliability, and auditability of remote shell command execution. Attached Figure Description

[0043] Figure 1This is a flowchart illustrating a method for controlling the execution of remote shell commands, as provided in an embodiment of the present invention.

[0044] Figure 2 This is a schematic diagram of a module for a remote shell command execution control system provided in an embodiment of the present invention. Detailed Implementation

[0045] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0046] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0047] Secondly, the term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places throughout this specification does not necessarily refer to the same embodiment, nor is it a single embodiment or an embodiment selectively excluded from other embodiments.

[0048] Reference Figures 1-2 As shown.

[0049] The embodiments further illustrate the remote shell command execution control method, system, and storage medium proposed in this invention.

[0050] A method for controlling the execution of remote shell commands, comprising the following steps:

[0051] Retrieve the shell command string to be executed;

[0052] By actively collecting or receiving tool call requests from AI agents, the shell command strings to be executed by the user or agent can be extracted.

[0053] The shell command string is categorized for side effects to obtain the corresponding execution decision; the execution decision includes one of the following: allow execution, require confirmation before execution, or prohibit execution.

[0054] Categorize and process the side effects of shell command strings, including:

[0055] The features extracted from the shell command string are matched against a preset rule set to obtain the matching results; where the preset rule set corresponds to different side effect categories;

[0056] The set of side effect categories for the shell command string is determined based on the matching results, and an execution decision is generated based on the set of side effect categories and the preset decision strategy.

[0057] The default rule set includes a strong blocking rule set and a rule set requiring confirmation;

[0058] When the shell command string matches the set of strong blocking rules, the generated execution decision is to prohibit execution;

[0059] When the shell command string matches the rule set that requires confirmation, the generated execution decision is to execute after confirmation.

[0060] The strong blocking rule set is used to match command patterns including:

[0061] This includes commands that connect download tools to a shell interpreter via a pipe, as well as commands that contain extremely high-risk file system corruption operation modes.

[0062] The obtained shell command string to be executed is processed for side effects classification to obtain the execution decision corresponding to the command. The execution decision is divided into allowed execution, execution after confirmation, and prohibited execution. All execution control logic for the command will be based on the decision.

[0063] Specifically, the classification and processing of side effects of shell command strings involves several key steps. The first step is feature extraction and rule matching. The system extracts key features of the shell command string to be processed, including the command's tool name, operators, execution logic, and parameter pointers. These extracted features are matched with a preset rule set to obtain corresponding matching results. Each rule in the preset rule set corresponds to a different side effect category, which is the type of risk or scope of impact that the command may bring. Through the matching process, the risk category to which the command belongs can be identified. The second step is to generate an execution decision based on the matching results. The system determines the set of side effect categories corresponding to the shell command string based on the matching results, and then combines this with a preset decision strategy to generate the final execution decision. This decision strategy matches the corresponding control method based on the risk category and risk level of the command. To achieve tiered control, the preset rule sets are divided into strong blocking rule sets and confirmation-required rule sets, each corresponding to different risk control levels: when a shell command string matches a strong blocking rule set, it indicates that the command has an extremely high security risk, and the generated execution decision is to prohibit execution; when a shell command string matches a confirmation-required rule set, it indicates that the command has a risk but is not absolutely unexecutable, and the generated execution decision is to execute only after confirmation, requiring confirmation from the user or relevant parties; commands that do not match either of these rule sets are generated by default as allowed execution. The strong blocking rule set is specifically designed to match command patterns with extremely high destructive risks. It includes two typical high-risk command types: one type consists of commands that involve a piped connection between a download tool and a shell interpreter. These commands typically download scripts directly from a remote address and pass them to the shell for execution via a pipe, posing a serious security risk of malicious code injection and execution of unverified scripts. Execution of these commands could lead to system intrusion or malicious code execution. The other type consists of commands containing extremely high-risk file system corruption operations (such as recursive deletion of the root directory or equivalent extremely high-risk targets, formatting storage devices, etc.). Execution of these commands would cause irreparable damage to the system; therefore, commands matching the strong blocking rule set are prohibited from execution. For risky operations such as deletion that point to a specific path, the confirmation rule set is used, and execution is only permitted after receiving confirmation.

[0064] If the execution decision is to prohibit execution, the automatic execution process of the shell command string is terminated, and security guidance information related to the command is output. When the command belongs to the type of downloading and pipe-executing a remote script, the security guidance information includes an executable task plan for guiding secure operations, specifically including the following steps:

[0065] When the shell command string is a command to download and pipe a remote script, resolve the remote address of the script;

[0066] Download the script content from the remote address to the preset cache path in the remote terminal session, preview the script content, perform syntax checks on the script content, and output prompts to guide the user to manually execute the script in the cache path;

[0067] When the system recognizes that the shell command string to be processed is a command to download and pipe-execute a remote script, it parses the command to extract and locate the script's remote address, which is the script's download source address. This clarifies the origin of the object to be processed and provides basic information for secure processing. After address parsing, the original command's pipe-execution logic is not executed directly. Instead, a preset secure processing flow is initiated, downloading the script content corresponding to the remote address to a preset cache path within the remote terminal session.

[0068] The script content, which would normally be transmitted directly to the shell interpreter, is first stored on the local machine as a file accessible to the remote session.

[0069] This system cuts off the direct link between download and execution, preventing scripts from being executed without any checks. It supports user or system preview of script content in the cache path, allowing users to directly view the complete script code, identify whether it contains malicious instructions, prohibited or unexpected logic, and enable manual auditing of script content downloaded to the preset cache path.

[0070] The system performs syntax checks to verify the script's syntax is correct, preventing syntax errors or tampering, and also initially filters out some malicious scripts with abnormal formats. It outputs clear prompts to guide users to manually execute scripts from the cached path, rather than having them executed automatically by the system. This returns final execution control to the user, allowing them to decide whether to execute the script after previewing the content and assessing the risks. This transforms the originally high-risk automated execution process into a controllable, auditable, and verifiable secure operation process. It not only meets users' needs to obtain and run scripts but also fundamentally eliminates the security risks associated with downloading and pipe-executing remote script commands, achieving secure control over high-risk shell commands.

[0071] If the shell command string is identified as belonging to the default write file command type, then according to the default reliable execution protocol, the shell command string is converted into a sequence of subcommands to be executed sequentially on the remote end, specifically including the following steps:

[0072] When the shell command string is a command to perform in-situ text replacement on the target file, a preview of the differences between the content after the replacement and the source file is generated, backed up before writing, written back to the target file through a temporary file, and a verification step is performed after writing.

[0073] When the shell command string is a command to create or write a file using the heredoc syntax, check if the command's termination marker is completely closed.

[0074] If the termination marker is not fully closed, the execution of the write step is blocked and a prompt message is output; the subcommand sequence includes steps for previewing the content to be written or changes, and backing up the target file before performing the write operation;

[0075] This system constructs a secure execution flow that combines syntax validation and risk control for shell commands that create or write files using heredoc syntax. Through pre-processing syntax checks, risk blocking, and step-by-step execution mechanisms, it avoids file corruption and data loss caused by abnormal writes or accidental operations. The system performs type identification on the acquired shell command string. When the command is determined to be a heredoc command for creating or writing files, a termination marker integrity check is immediately initiated. Heredoc syntax relies on specific termination markers to define the boundaries of the content to be written. If the termination marker is not fully closed, the write logic may continuously wait for input, accidentally write invalid data, or even cause system freezes or file content corruption. Therefore, the termination marker in the command is extracted and its complete matching and closure are checked. If the check results show that the termination marker is not fully closed, the execution of the write step is directly blocked, and a clear prompt message is output to inform the user that the command has a syntax defect, thus preventing the execution of abnormal write operations. If the termination marker is fully closed, the original heredoc command is converted into a sequence of subcommands to be executed sequentially on the remote end according to a preset reliability execution protocol. This sequence contains several key steps to ensure write safety and reliability, including a step to preview the content to be written or changes, allowing the user to view the complete content of the target file to be written before writing, confirming whether the content meets expectations, and preventing erroneous content from being written. It also includes a step to back up the target file before executing the write operation, creating a backup copy of the original target file before the write operation is executed. Even if errors occur during the write process or the write result does not meet expectations, the original file data can be quickly restored from the backup file, avoiding data loss or file corruption. The entire process blocks abnormal commands through pre-process syntax verification, and controls legitimate write operations through step-by-step execution, backup, and preview mechanisms, achieving full-process security control of heredoc file write commands, effectively improving the reliability and security of file write operations.

[0076] In a remote terminal session, the execution of corresponding commands or steps is controlled based on execution decisions, subcommand sequences, and / or security boot information.

[0077] The subcommand sequence also includes a verification step, which verifies whether the write result meets expectations after the write step is executed.

[0078] The remote terminal session serves as the actual carrier for command execution. Based on the execution decision, sub-command sequence, or task plan, the corresponding command or step is executed in a scenario-based control manner: when the execution decision is to allow execution, the terminal session will directly execute the verified and valid shell command; when the execution decision is to require confirmation before execution, the terminal session will pause the execution process, send a confirmation request to the user, and continue executing the command after receiving a clear confirmation instruction from the user.

[0079] When the execution decision is to prohibit execution, the terminal session terminates the automatic execution process of the original command and outputs security guidance information; for commands that download and pipe execute remote scripts, the user can be guided to complete the relevant operations manually and in an auditable manner according to the executable task plan;

[0080] For file-writing commands that are converted into sub-command sequences, the terminal session executes backup, preview, and write steps in a preset order, ensuring that each operation proceeds under controlled conditions. In addition, a verification step is set up for the sub-command sequences of file-writing commands. This step is initiated after the write step is completed. It verifies whether the write result matches expectations by reading the target file content, comparing it with the expected write data, checking file integrity, or comparing hash values. If the verification result matches expectations, the write operation is confirmed to have been successfully completed. If the verification finds discrepancies, file corruption, or write failure, the terminal session triggers exception handling logic, such as automatically restoring the backup file, outputting an error message to the user, and terminating subsequent operations, to prevent invalid or erroneous write results from affecting system operation. This approach achieves hierarchical management of commands with different risk levels through scenario-based control of the remote terminal session, and constructs an operational closed loop through the post-write verification step, effectively ensuring the security and reliability of remote shell command execution.

[0081] It also includes the following steps:

[0082] When receiving a tool invocation request from the AI ​​agent, extract the command string to be executed from the request;

[0083] The extracted command string is subjected to side effect classification processing, and the execution decision controls whether the command string is executed in the remote terminal session.

[0084] By capturing tool call requests from AI agents, extracting command strings, and enforcing side effect classification, the system achieves end-to-end risk control over AI-generated commands. First, the system, acting as a security middleware layer, receives tool call requests from AI agents. These requests typically contain shell command execution requests initiated by the AI ​​agent to complete specific tasks. The system accurately extracts the shell command string to be executed from the request parameters or messages, ensuring that all shell commands initiated by the AI ​​agent are fully captured and do not bypass the control process. After extracting the command string, the system enforces side effect classification. Regardless of the content of the command generated by the AI ​​agent, it must pass through a pre-defined risk identification process: the system extracts key features of the command and matches them against pre-defined strong blocking rule sets and confirmation rule sets to identify whether the command belongs to a high-risk mode, such as commands that connect download tools to a shell interpreter pipe, or extremely high-risk file corruption operations.

[0085] For potentially risky command types such as writing to files using the heredoc syntax, corresponding execution decisions are generated based on the matching results, including allowing execution, requiring confirmation before execution, and prohibiting execution. Alternatively, file writing commands can be converted into a sequence of subcommands that include backup, preview, and verification steps. This allows for risk-based classification and control of commands generated by the AI ​​agent, preventing the direct execution of high-risk commands initiated by the AI ​​agent due to logical defects, malicious instructions, or generation errors. This blocks the threat of unsafe operations to remote terminal systems from the source and ensures system security and operational reliability during the execution of shell commands by the AI ​​agent.

[0086] A remote shell command execution control system, comprising:

[0087] The `get` module retrieves the shell command string to be executed.

[0088] Processing module: Classifies shell command strings for side effects and obtains the corresponding execution decision; the execution decision includes one of the following: allow execution, require confirmation before execution, or prohibit execution.

[0089] Generation module: If the execution decision is to prohibit execution, the automatic execution process of the shell command string is terminated, and security boot information related to the command is output;

[0090] Conversion module: If the shell command string is identified as belonging to the default write file command type, the shell command string is converted into a sequence of subcommands to be executed sequentially on the remote end according to the default reliable execution protocol; wherein, the subcommand sequence includes steps for previewing the content to be written or changes, and backing up the target file before executing the write;

[0091] Control module: In a remote terminal session, it controls the execution of corresponding commands or steps based on the execution decision, sub-command sequence, and / or security guidance information; if the execution decision requires confirmation before execution, it executes the shell command string and / or the converted sub-command sequence in the remote terminal session after receiving the confirmation instruction.

[0092] A storage medium storing a computer program that, when executed by a processor, implements a method for controlling the execution of remote shell commands.

[0093] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0094] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method of controlling execution of a remote shell command, characterized by, Includes the following steps: Retrieve the shell command string to be executed; The shell command string is categorized for side effects to obtain the corresponding execution decision; wherein the execution decision includes one of allowing execution, requiring confirmation before execution, or prohibiting execution. If the execution decision is to prohibit execution, the automatic execution process of the shell command string is terminated, and security boot information related to the command is output. If the decision to execute requires confirmation, then upon receiving the confirmation instruction, the shell command string and / or the converted subcommand sequence will be executed in the remote terminal session. If the shell command string is identified as belonging to a preset file write command type, then according to the preset reliability execution protocol, the shell command string is converted into a sequence of subcommands to be executed sequentially on the remote end; wherein, the subcommand sequence includes steps for previewing the content to be written or changes, and backing up the target file before executing the write; In a remote terminal session, the execution of corresponding commands or steps is controlled based on execution decisions, subcommand sequences, and / or security boot information.

2. The method of claim 1, wherein, Categorize and process the side effects of shell command strings, including: The features of the extracted shell command string are matched with a preset rule set to obtain the matching result; wherein, the preset rule set corresponds to different side effect categories; The set of side effect categories for the shell command string is determined based on the matching results, and an execution decision is generated based on the set of side effect categories and the preset decision strategy.

3. The method for controlling the execution of remote shell commands according to claim 2, characterized in that, The preset rule set includes a strong blocking rule set and a confirmation-required rule set; When the shell command string matches the set of strong blocking rules, the generated execution decision is to prohibit execution; When the shell command string matches the rule set that requires confirmation, the generated execution decision is to execute after confirmation.

4. The method for controlling the execution of remote shell commands according to claim 3, characterized in that, The strong blocking rule set is used to match command patterns including: This includes commands that connect download tools to a shell interpreter via a pipe, as well as commands that contain extremely high-risk file system corruption operation modes.

5. The method for controlling the execution of remote shell commands according to claim 4, characterized in that, The secure boot information includes: when the shell command string is a command to download and pipe-execute a remote script, generating an executable task plan for bootstrapping secure operations; the executable task plan specifically includes the following steps: When the shell command string is a command to download and pipe a remote script, resolve the remote address of the script; The script content from the remote address is downloaded to a preset cache path in the remote terminal session, the script content is previewed, the script content is syntax checked, and prompts are output to guide the user to manually execute the script in the cache path.

6. The method for controlling the execution of remote shell commands according to claim 1, characterized in that, Converting a shell command string into a sequence of subcommands executed sequentially on a remote end includes at least some of the following features: when the shell command string is a command to create or write a file using heredoc syntax, checking whether the command's termination marker is fully closed; if the termination marker is not fully closed, blocking the execution of the write step and outputting a prompt message; the subcommand sequence also includes an execution verification step for verifying whether the write result meets expectations after the write step is executed. The preset file writing command type also includes commands for performing in-situ text replacement on the target file; The subcommand sequence also includes: generating a preview of the differences between the replaced content and the source file, backing up before writing, writing back to the target file via a temporary file, and verification steps after writing.

7. The method for controlling the execution of remote shell commands according to claim 1, characterized in that, It also includes the following steps: When receiving a tool invocation request from the AI ​​agent, extract the command string to be executed from the request; The extracted command string is subjected to side effect classification processing, and the execution decision controls whether the command string is executed in the remote terminal session.

8. A remote shell command execution control system, applied to the remote shell command execution control method according to any one of claims 1-7, characterized in that, include: The `get` module retrieves the shell command string to be executed. Processing module: performs side effect classification on shell command strings to obtain the execution decision corresponding to the shell command string; wherein, the execution decision includes one of allowing execution, requiring confirmation before execution, and prohibiting execution; Generation module: If the execution decision is to prohibit execution, the automatic execution process of the shell command string is terminated, and security guidance information related to the command is output; if the execution decision is to require confirmation before execution, the shell command string and / or the converted sub-command sequence are executed in the remote terminal session after receiving the confirmation instruction. Conversion module: If the shell command string is identified as belonging to the preset file write command type, the shell command string is converted into a sequence of subcommands to be executed sequentially on the remote end according to the preset reliable execution protocol; wherein, the subcommand sequence includes steps for previewing the content to be written or changes, and backing up the target file before executing the write; Control module: In a remote terminal session, it controls the execution of corresponding commands or steps based on execution decisions, sub-command sequences, and / or security boot information.

9. A storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a method for controlling the execution of a remote shell command as described in any one of claims 1 to 7.