Link forwarding method and system based on SSH protocol
Through the combination of Lua script layer and interceptor layer, the forwarding of SSH protocol container links is realized, which solves the problems of traditional SSH protocol connection convenience and low security. It is suitable for dynamic and large-scale container environments, simplifying configuration and management and Improved security.
Patent Information
- Application Number
- CN202311385596.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-24
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-10-24
AI Technical Summary
The traditional SSH protocol cannot directly connect to the container, so users need to operate through external docker native commands. The connection method is low in convenience and security.
Using the link forwarding method based on the SSH protocol, the user's SSH establishment request is received through the Lua script layer, the container information is converted into the target service IP, and the interceptor layer initiates the SSH connection request to realize link forwarding to the target container, simplifying user operations and Improve security.
It improves the convenience on the user side and the security of the SSH protocol, avoids data leaks and man-in-the-middle attacks, simplifies the configuration and management of containers, and is suitable for dynamic and large-scale container environments.
Smart Images

Figure CN117478368B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a link forwarding method and system based on the SSH protocol. Background Art
[0002] With the development of cloud computing and container technology, enterprises and developers are adopting containerized applications in large quantities to meet the needs of rapid deployment, scalability, and high availability. In this context, it is particularly important to effectively access and manage services in containers. As a widely used secure remote access protocol, the Secure Shell (SSH) protocol can provide users with secure access and management functions for services in containers.
[0003] However, the traditional SSH protocol cannot directly connect to the container. Users need to execute it through external Docker native commands. For the user side, the specific user needs to type the command on the host machine, and then use the command to connect to the container through the SSH protocol. The above connection method has low convenience and security. Summary of the invention
[0004] The present invention provides a link forwarding method and system based on SSH protocol, which are used to solve the problems of low convenience and security of the connection mode in the prior art.
[0005] The present invention provides a link forwarding method based on SSH protocol, which is applied to a link forwarding system based on SSH protocol. The system comprises: a lua script layer and an interceptor layer;
[0006] The method comprises:
[0007] The lua script layer receives an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link;
[0008] The lua script layer converts the container information into the corresponding target service ip;
[0009] The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity;
[0010] After the interceptor layer establishes SSH connection with the target container, the interceptor layer forwards the corresponding SSH link to the target container.
[0011] According to a link forwarding method based on the SSH protocol provided by the present invention, the interceptor layer initiates an SSH connection request to a target container corresponding to the target service IP, including:
[0012] When the interceptor layer determines that the target service IP is legal, it initiates the SSH connection request to the target container corresponding to the target service IP.
[0013] According to a link forwarding method based on the SSH protocol provided by the present invention, after the lua script layer receives an SSH establishment request from a user, the method further includes:
[0014] The lua script layer performs an authentication operation on the user;
[0015] The lua script layer converts the container information into the corresponding target service IP, including:
[0016] When it is determined that the user authentication is successful, the Lua script layer converts the container information into a corresponding target service IP.
[0017] According to a link forwarding method based on the SSH protocol provided by the present invention, the lua script layer converts the container information into the corresponding target service IP, including:
[0018] The lua script layer obtains the target service IP corresponding to the container information from a preset database, and sends the target service IP to the interceptor layer.
[0019] According to a link forwarding method based on the SSH protocol provided by the present invention, after the interceptor layer establishes SSH connection with the target container and forwards the corresponding SSH link to the target container, the method further includes:
[0020] In response to a data packet corresponding to the container information from the user, the interceptor layer translates the data packet and transmits the translated data packet to the target container.
[0021] According to a link forwarding method based on the SSH protocol provided by the present invention, the method further includes:
[0022] When the Lua script layer determines that a target event occurs, the Lua script layer performs a blocking operation on the target service IP;
[0023] The occurrence of the target event includes at least one of the following:
[0024] The user performs a prohibited operation;
[0025] The SSH establishment request sent by the user times out.
[0026] According to a link forwarding method based on the SSH protocol provided by the present invention, the lua script layer receives an SSH establishment request from a user, comprising:
[0027] The lua script layer receives the SSH establishment request from the user through a web page or an SSH tool.
[0028] The present invention also provides a link forwarding system based on the SSH protocol, comprising:
[0029] Lua scripting layer, used for:
[0030] Receive an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link;
[0031] Convert the container information to the corresponding target service IP;
[0032] Interceptor layer, used to:
[0033] Initiate an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity;
[0034] After establishing SSH connection with the target container, the corresponding SSH link is forwarded to the target container.
[0035] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the link forwarding method based on the SSH protocol as described above is implemented.
[0036] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the link forwarding method based on the SSH protocol as described above is implemented.
[0037] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the link forwarding method based on the SSH protocol as described above is implemented.
[0038] The present invention provides a link forwarding method and system based on the SSH protocol. The method is applied to a link forwarding system based on the SSH protocol. The system includes a Lua script layer and an interceptor layer. First, a user sends an SSH establishment request to the Lua script layer. The Lua script layer can convert container information in the SSH establishment request into a corresponding target service IP. Then, the interceptor layer initiates an SSH connection request to a target container corresponding to the target service IP, so as to request SSH connection to the target container. After the connection is established, the interceptor layer can forward the corresponding SSH link in the SSH establishment request to the target container, so as to realize the forwarding of the SSH link between the user and the target container. Compared with the related art in which users need to use external docker native commands to connect to containers through the SSH protocol, in the embodiment of the present invention, users can send container information to the lua script layer, so that the lua script layer converts the container information, and then the interceptor layer executes related operations of the docker native command to connect to the target container. For the user side, the user does not need to enter complex docker native commands to establish a connection with the target container, which improves the convenience of establishing a connection. In addition, the target container will not be entered directly through the host machine. In the process of realizing container link forwarding, the security of the SSH protocol can be ensured, and security issues such as data leakage and man-in-the-middle attacks can be prevented, thereby effectively improving security. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0040] Figure 1 This is one of the flow charts of the link forwarding method based on the SSH protocol provided by the present invention;
[0041] Figure 2 This is the second flow chart of the link forwarding method based on the SSH protocol provided by the present invention;
[0042] Figure 3 It is a flow chart of a link forwarding system based on the SSH protocol provided by the present invention;
[0043] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] The following describes the link forwarding method and system based on the SSH protocol of the present invention in conjunction with the accompanying drawings.
[0046] Figure 1 It is one of the flow charts of the link forwarding method based on SSH protocol provided by the present invention, such as Figure 1 As shown, the method is applied to a link forwarding system based on the SSH protocol, and the system includes: a lua script layer and an interceptor layer. The method includes steps 101 and 104; wherein:
[0047] Step 101, the lua script layer receives an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link.
[0048] Step 102: The Lua script layer converts the container information into the corresponding target service IP.
[0049] Step 103: The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity.
[0050] Step 104: After establishing SSH connection with the target container, the interceptor layer forwards the corresponding SSH link to the target container.
[0051] In the related art, the traditional SSH protocol cannot directly connect to the container. Users need to execute it through external docker commands, and cannot connect through web pages or SSH tools. In addition, as the number of containers continues to increase, it becomes increasingly difficult to manage the software installed in these containers. Therefore, a more flexible and scalable SSH protocol container link forwarding solution is needed to meet the needs of dynamic and large-scale container environments.
[0052] Nginx lua is a module that embeds the lua scripting language in Nginx, which allows developers to use lua to write high-performance web applications and extend the functionality of Nginx. The Nginx lua module is implemented based on LuaJIT (a high-performance lua just-in-time compiler), so it has the characteristics of high performance and low memory usage.
[0053] Using Nginx lua, you can implement the following functions in Nginx:
[0054] 1) Dynamically modify requests and responses: Use Lua scripts to modify requests and responses in real time during Nginx's processing flow, such as rewriting the Uniform Resource Locator (URL), modifying request headers, adding or deleting response headers, etc.
[0055] 2) High-performance routing and load balancing: Use Lua scripts to implement highly customizable routing rules and load balancing strategies to meet the needs of specific scenarios.
[0056] 3) User authentication and access control: Use Lua scripts to implement user authentication and access control functions, such as limiting access to specific IP addresses and implementing Application Programming Interface (API) permission control.
[0057] 4) Cache control and optimization: Use Lua scripts to dynamically adjust cache strategies to improve the response speed of web applications and reduce the pressure on backend servers.
[0058] 5) Implement custom logic and functions: Use Lua scripts to implement various custom logic and functions in Nginx, such as implementing A / B testing, dynamically generating Hypertext Markup Language (HTML) pages, etc.
[0059] As a lightweight scripting language, Lua has the characteristics of concise syntax, excellent execution performance and easy integration. As a high-performance web server and reverse proxy server, Nginx has been widely used in the Internet field. Based on the Lua module of Nginx, Lua scripts can be embedded in Nginx to achieve high-performance web applications and customized functions.
[0060] In view of the above problems and technical background, the embodiment of the present invention proposes a link forwarding method based on the SSH protocol, which is based on Lua forwarding and has high practical value. The method can make full use of the advantages of the Lua language and combine the high performance characteristics of Nginx to achieve flexible and efficient forwarding and management of SSH services in containers.
[0061] Specifically, the method of the embodiment of the present invention can be applied to a link forwarding system based on the SSH protocol, which includes a lua script layer and an interceptor layer. The user first sends an SSH establishment request to the lua script layer, and the SSH establishment request includes container information and a corresponding SSH link. The container information can be understood as indicating which one or several containers the user needs to establish a connection with, and the corresponding SSH link can be a link that needs to be forwarded to the container indicated by the container information.
[0062] Optionally, the container information may include a local container group (pod) name or a k8s-dns domain name.
[0063] Optionally, the implementation of the lua script layer receiving the SSH establishment request from the user may include:
[0064] The lua script layer receives the SSH establishment request from the user through a web page or an SSH tool.
[0065] Specifically, the user can send an SSH establishment request to the lua script layer through a web page or an SSH tool, without the need for the user to enter a docker command on the host machine to establish a connection with the container, which simplifies the operation on the user side and improves the convenience on the user side. Moreover, if the user directly enters the docker command on the host machine, that is, the connection between the host machine and the container is directly established through the docker command, any container can be entered on the host machine, and the security of the container is low. In the present invention, the user sends an SSH establishment request to the lua script layer through a web page or an SSH tool, and will not directly connect to the container, which effectively improves the security of the container.
[0066] Optionally, the SSH tool may include a shell connection tool, such as secretcrt xshell.
[0067] After receiving the SSH establishment request, the Lua script layer can convert the container information in the SSH establishment request into the corresponding target service IP.
[0068] For example, when a user accesses a container from a browser, he or she enters an address, which needs to be converted by the Lua script layer. For example, if a user enters www.abc.com, the Lua script layer needs to convert it to 192.169.1.1 (service IP).
[0069] The Lua script layer then sends the SSH link and the target service IP to the interceptor layer, which initiates an SSH connection request to the target container corresponding to the target service IP to request SSH connection to the target container. After the connection is established, the interceptor layer can forward the corresponding SSH link in the SSH establishment request to the target container, thereby realizing the forwarding of the SSH link between the user and the target container.
[0070] Optionally, the implementation method of the Lua script layer converting the container information into the corresponding target service IP may include:
[0071] The lua script layer obtains the target service IP corresponding to the container information from a preset database, and sends the target service IP to the interceptor layer.
[0072] Specifically, the Lua script layer can obtain the target service IP (service IP) corresponding to the container information from a preset database, such as a Redis library. The Lua script layer adds the IP to the parameters and sends it to the interceptor layer. Then the interceptor layer can initiate a new SSH connection request to the corresponding target container based on the target service IP to establish SSH connection with the target container. The currently used container can be expanded or reduced by adding or reducing the correspondence between container information, service IP and container in the database. There is no need to make adjustments by modifying the Docker native command as required by related technologies. This simplifies the configuration and management of containers, so that when the number and status of containers change, the forwarding rules can be adjusted in real time to ensure that users can smoothly access the target container.
[0073] Optionally, the number of target containers may be one or more, and the interceptor layer may initiate an SSH connection request or may be used to establish an SSH connection with a group of containers.
[0074] In the link forwarding method based on the SSH protocol provided in the embodiment of the present invention, compared with the related art in which the user needs to use an external docker native command to connect to the container through the SSH protocol, in the embodiment of the present invention, the user can send container information to the lua script layer, so that the lua script layer converts the container information, and then the interceptor layer executes the relevant operations of the docker native command to connect to the target container. For the user side, the user does not need to enter complex docker native commands to establish a connection with the target container, which improves the convenience of establishing a connection, and will not directly enter the target container through the host machine. In the process of realizing container link forwarding, the security of the SSH protocol can be ensured, and security issues such as data leakage and man-in-the-middle attacks can be prevented, thereby effectively improving security.
[0075] Optionally, after the lua script layer receives the SSH establishment request from the user, the lua script layer may perform an authentication operation on the user;
[0076] The implementation method of the Lua script layer converting the container information into the corresponding target service IP may include:
[0077] When it is determined that the user authentication is successful, the Lua script layer converts the container information into a corresponding target service IP.
[0078] Specifically, the Lua script layer can be used to perform authentication operations on users who need to establish an SSH connection. If the user is authenticated successfully, the Lua script layer will convert the container information into the corresponding target service IP, which can effectively intercept the establishment request initiated by the user who failed the authentication, prevent the user from operating out of bounds, and improve the security of the subsequent establishment of the SSH forwarding path and forwarding of the SSH link.
[0079] Optionally, the implementation method of the interceptor layer initiating an SSH connection request to the target container corresponding to the target service IP may include:
[0080] When the interceptor layer determines that the target service IP is legal, it initiates the SSH connection request to the target container corresponding to the target service IP.
[0081] Specifically, the interceptor layer can initiate an SSH connection request to the target container corresponding to the target service IP when it determines that the target service IP is legal, so as to establish an SSH forwarding path between the user and the target container. This can intercept links with illegal IPs to a certain extent, prevent users from crossing the boundary, improve the security of subsequent establishment of SSH forwarding paths and forwarding SSH links, and realize the configuration of relevant defense strategies by level.
[0082] It should be noted that the target service IP is legal. For example, the IP assigned to the container is 192.168.1.55. At this time, the IP entered by the user is a high-authority IP, such as 192.168.1.1. It is necessary to determine whether the IP is the user's real IP, that is, whether the target service IP is legal. Then, the user access can be denied or released based on the judgment result.
[0083] Optionally, after the interceptor layer establishes SSH connection with the target container and forwards the corresponding SSH link to the target container, in response to a data packet corresponding to the container information from the user, the interceptor layer may translate the data packet and transmit the translated data packet to the target container.
[0084] Specifically, after the interceptor layer establishes SSH connection with the target container and forwards the corresponding SSH link to the target container, it can start forwarding data packets between the user and the target container. Specifically, it can translate the data packets corresponding to the user's container information and then transmit the translated data packets to the target container. This can avoid the incompatibility problem between the data packets to be transmitted and the target container, thereby improving the versatility of the link forwarding system.
[0085] It should be noted that the translation of data packets by the interceptor layer is only one of the many functions that can be realized, and other functions can also be realized according to actual conditions.
[0086] Optionally, the Lua script layer may perform a blocking operation on the target service IP when determining that a target event occurs;
[0087] The occurrence of the target event includes at least one of the following:
[0088] 1) The user performs a prohibited operation;
[0089] 2) The SSH establishment request sent by the user times out.
[0090] Specifically, the Lua script layer can block the target service IP when it determines that the user has performed a prohibited operation, or the sent SSH establishment request has timed out, or in other practical situations. After blocking, the user cannot establish a connection with the container through the target service IP.
[0091] Optionally, the Lua script layer can also perform an unblocking operation on the target service IP when the target event no longer occurs. The unblocked target service IP can be used normally, which can be understood as the user can now establish a connection with the container through the target service IP.
[0092] The following example illustrates a link forwarding method based on the SSH protocol provided by an embodiment of the present invention.
[0093] The technical problem to be solved by the present invention is how to achieve flexible and efficient forwarding and management of SSH protocol container links in a dynamic, large-scale container environment. Specifically, the present invention needs to solve the following technical problems:
[0094] 1) How to simplify configuration and management: Design a method to achieve simple configuration and management of SSH protocol container link forwarding when the number of containers is constantly changing, avoiding the need to use Docker native commands to use SSH tools to connect.
[0095] 2) How to improve forwarding performance: Under the premise of ensuring security, improve the performance of SSH protocol container link forwarding, reduce latency, and meet the high concurrency and high availability requirements in large-scale container environments.
[0096] 3) How to implement dynamic container selection and forwarding: Design a scalable container selection and forwarding strategy so that when the number and status of containers change, the forwarding rules can be adjusted in real time to ensure that users can successfully access the target container.
[0097] 4) How to ensure the security of the SSH protocol: In the process of implementing container link forwarding, ensure the security of the SSH protocol to prevent security issues such as data leakage and man-in-the-middle attacks.
[0098] In order to achieve simple configuration and management of SSH protocol container link forwarding when the number of containers is constantly changing, it is avoided that the docker native command can be used to use the ssh tool for linking. Through the present invention, the shell tool can be directly used to directly connect to the pod in k8s, and the relevant containers can be directly installed and deployed through the shell tool.
[0099] Figure 2 FIG. 2 is a flow chart of the link forwarding method based on the SSH protocol provided by the present invention. Figure 2 As shown, there are two modules in the system of the present invention, namely the Lua script layer and the SSH interceptor layer.
[0100] Among them, the function of the Lua script layer is: according to the local pod name or k8s-dns domain name entered by the user, the corresponding domain name or name is retrieved from the corresponding service IP saved in Redis when the container is created; at the same time, the Lua script layer adds the service IP to the parameters and sends it to the SSH interceptor layer.
[0101] The SSH interceptor layer initiates a new SSH request to the pod based on the service IP. After SSH is connected, the SSH link initiated by the user is forwarded to the new pod, so that the user only needs to pass a mapping name, such as: k8s-dns, pod name, to support direct connection to the pod through the SSH protocol.
[0102] The embodiments of the present invention have at least the following beneficial effects:
[0103] 1) Simplified configuration and management: The present invention reduces the configuration and management difficulty of SSH protocol container link forwarding by using Lua scripts and Nginx modules. Users do not need to perform complex port mapping and load balancing configuration, which greatly reduces deployment and maintenance costs.
[0104] 2) Improving forwarding performance: Due to the lightweight characteristics of the Lua language and the high performance characteristics of Nginx, the present invention improves the forwarding performance and the response speed of the system while realizing SSH protocol container link forwarding.
[0105] 3) Dynamic container selection and forwarding: This paper designs a scalable container selection and forwarding strategy, which can adjust the forwarding rules in real time when the number and status of containers change, ensuring that users can smoothly access the target container. This helps to cope with changing needs in dynamic and large-scale container environments.
[0106] 4) Ensure the security of the SSH protocol: In the process of implementing container link forwarding, the present invention fully considers the security of the SSH protocol and effectively prevents security issues such as data leakage and man-in-the-middle attacks.
[0107] In summary, the link forwarding method based on the SSH protocol proposed in the embodiment of the present invention can not only simplify configuration and management, improve forwarding performance, realize dynamic container selection and forwarding, but also ensure the security of the SSH protocol. The method is suitable for dynamic and large-scale container environments, and provides users with a flexible and efficient SSH protocol container link forwarding and management solution.
[0108] The following is a description of a link forwarding system based on the SSH protocol provided by the present invention. The link forwarding system based on the SSH protocol described below and the link forwarding method based on the SSH protocol described above can be referred to each other.
[0109] Figure 3 It is a flow chart of the link forwarding system based on SSH protocol provided by the present invention, such as Figure 3 As shown, the link forwarding system 300 based on the SSH protocol includes:
[0110] Lua script layer 301, used for:
[0111] Receive an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link;
[0112] Convert the container information to the corresponding target service IP;
[0113] The interceptor layer 302 is used to:
[0114] Initiate an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity;
[0115] After establishing SSH connection with the target container, the corresponding SSH link is forwarded to the target container.
[0116] In the link forwarding system based on SSH protocol provided in the embodiment of the present invention, the system includes a lua script layer and an interceptor layer, and the user first sends an SSH establishment request to the lua script layer, and the lua script layer can convert the container information in the SSH establishment request into the corresponding target service ip, and then the interceptor layer initiates an SSH connection request to the target container corresponding to the target service ip, for requesting SSH connection to the target container, and after the connection, the interceptor layer can forward the corresponding SSH link in the SSH establishment request to the target container, so as to realize the forwarding of the SSH link between the user and the target container. Compared with the user in the related art who needs to realize the connection of the container through the SSH protocol through the external docker native command, in the embodiment of the present invention, the user can send the container information to the lua script layer, so that the lua script layer converts the container information, and then the interceptor layer performs the relevant operations of the docker native command to connect with the target container, for the user side, the user does not need to enter the complex docker native command to establish the connection with the target container, which improves the convenience of establishing the connection, and will not directly enter the target container through the host machine, which can ensure the security of the SSH protocol in the process of realizing the container link forwarding, prevent data leakage, man-in-the-middle attacks and other security issues, and effectively improve the security.
[0117] Optionally, the interceptor layer 302 is specifically used for:
[0118] When it is determined that the target service IP is legal, the SSH connection request is initiated to the target container corresponding to the target service IP.
[0119] Optionally, the lua script layer 301 is specifically used for:
[0120] Performing an authentication operation on the user;
[0121] When it is determined that the user authentication is successful, the container information is converted into a corresponding target service IP.
[0122] Optionally, the lua script layer 301 is further specifically used for:
[0123] The target service IP corresponding to the container information is obtained from a preset database, and the target service IP is sent to the interceptor layer.
[0124] Optionally, the interceptor layer 302 is further specifically configured to: in response to a data packet corresponding to the container information from the user, translate the data packet, and transmit the translated data packet to the target container.
[0125] Optionally, the lua script layer 301 is further specifically used for:
[0126] When it is determined that a target event occurs, a blocking operation is performed on the target service IP;
[0127] The occurrence of the target event includes at least one of the following:
[0128] The user performs a prohibited operation;
[0129] The SSH establishment request sent by the user times out.
[0130] Optionally, the lua script layer 301 is further specifically used to: receive the SSH establishment request from the user through a web page or an SSH tool.
[0131] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the link forwarding method based on the SSH protocol, which is applied to the link forwarding system based on the SSH protocol, and the system includes: a lua script layer and an interceptor layer;
[0132] The method comprises:
[0133] The lua script layer receives an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link;
[0134] The lua script layer converts the container information into the corresponding target service ip;
[0135] The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity;
[0136] After the interceptor layer establishes SSH connection with the target container, the interceptor layer forwards the corresponding SSH link to the target container.
[0137] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the 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 a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. 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 codes.
[0138] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the link forwarding method based on the SSH protocol provided by the above methods, and is applied to a link forwarding system based on the SSH protocol, the system includes: a lua script layer and an interceptor layer;
[0139] The method comprises:
[0140] The lua script layer receives an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link;
[0141] The lua script layer converts the container information into the corresponding target service ip;
[0142] The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity;
[0143] After the interceptor layer establishes SSH connection with the target container, the interceptor layer forwards the corresponding SSH link to the target container.
[0144] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when executed by a processor to execute the link forwarding method based on the SSH protocol provided by the above methods, and is applied to a link forwarding system based on the SSH protocol, the system comprising: a lua script layer and an interceptor layer;
[0145] The method comprises:
[0146] The lua script layer receives an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link;
[0147] The lua script layer converts the container information into the corresponding target service ip;
[0148] The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity;
[0149] After the interceptor layer establishes SSH connection with the target container, the interceptor layer forwards the corresponding SSH link to the target container.
[0150] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0151] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A link forwarding method based on SSH protocol, characterized in that: Applied to a link forwarding system based on SSH protocol, the system comprises: a lua script layer and an interceptor layer; The method comprises: The lua script layer receives an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link; The lua script layer converts the container information into the corresponding target service ip; The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity; After the interceptor layer establishes SSH connection with the target container, the interceptor layer forwards the corresponding SSH link to the target container.
2. The link forwarding method based on the SSH protocol according to claim 1, characterized in that: The interceptor layer initiates an SSH connection request to the target container corresponding to the target service IP, including: When the interceptor layer determines that the target service IP is legal, it initiates the SSH connection request to the target container corresponding to the target service IP.
3. The link forwarding method based on the SSH protocol according to claim 1, characterized in that: After the lua script layer receives the SSH establishment request from the user, the method further includes: The lua script layer performs an authentication operation on the user; The lua script layer converts the container information into the corresponding target service IP, including: When it is determined that the user authentication is successful, the Lua script layer converts the container information into a corresponding target service IP.
4. The link forwarding method based on the SSH protocol according to any one of claims 1 to 3, characterized in that: The lua script layer converts the container information into the corresponding target service IP, including: The lua script layer obtains the target service IP corresponding to the container information from a preset database, and sends the target service IP to the interceptor layer.
5. The link forwarding method based on the SSH protocol according to any one of claims 1 to 3, characterized in that: After the interceptor layer establishes SSH connection with the target container and forwards the corresponding SSH link to the target container, the method further includes: In response to a data packet corresponding to the container information from the user, the interceptor layer translates the data packet and transmits the translated data packet to the target container.
6. The link forwarding method based on the SSH protocol according to any one of claims 1 to 3, characterized in that: The method further comprises: When the Lua script layer determines that a target event occurs, the Lua script layer performs a blocking operation on the target service IP; The occurrence of the target event includes at least one of the following: The user performs a prohibited operation; The SSH establishment request sent by the user times out.
7. The link forwarding method based on the SSH protocol according to any one of claims 1 to 3, characterized in that: The lua script layer receives an SSH establishment request from a user, including: The lua script layer receives the SSH establishment request from the user through a web page or an SSH tool.
8. A link forwarding system based on SSH protocol, characterized in that: include: Lua scripting layer, used for: Receive an SSH establishment request from a user; wherein the SSH establishment request includes container information and a corresponding SSH link; Convert the container information to the corresponding target service IP; Interceptor layer, used to: Initiate an SSH connection request to the target container corresponding to the target service IP; wherein the SSH connection request is used to request SSH connectivity; After establishing SSH connection with the target container, the corresponding SSH link is forwarded to the target container.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the link forwarding method based on the SSH protocol as described in any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the link forwarding method based on the SSH protocol as claimed in any one of claims 1 to 7 is implemented.
