Skip to main content

Use SSH Tunnel Accessing container services

SSH Tunnel It is a method of encryption SSH The method of forwarding network connections on local or remote computers through connections. You can use SSH Tunnel To access services protected by firewalls on remote servers. Without exposing the port directly to the public Internet.

There are two ways to pass through SSH Verification method for accessing machines:

  1. Password based verification: This method requires the user to enter a password for authentication.
  2. Public key based verification: This method uses public key encryption technology for identity verification. It involves generating a pair of keys on the client side (Public key and private key), And add the public key to HyperAI. The private key is securely stored on the local machine. And used for authentication without the need for a password.

Use password

HyperAI of SSH The service provides a password login method by default. If you don't want to configure the key, you can also follow the instructions [Access with password SSH](/docs/gear/ssh/#Use password) The way.

To configure ssh key

If you already have SSH secret key. You can skip this step. Please find the relevant information in [Prepare public key](/docs/gear/ssh#Prepare public key) see.

How to use commands to access ports

1. Start a HyperAI The workspace

copy "SSH visit" Command from the panel to one's own computer terminal. Confirm if the container can be successfully accessed. If you see the following content, it means that you have successfully accessed the container.

$ ssh root@ssh. HyperAI.com -p31552

Last login: Fri May 5 03:47:16 2023 from 10.110.14.192
HyperAI

Catalog Description

- /hyperai/home Data storage address in workspace. After the container stops. The contents of this directory will not be deleted
- /hyperai/input/input0 - /hyperai/input/input4 Bind addresses to the dataset. This address has read-only permission. Storage capacity that does not occupy workspace. Supports simultaneous binding at most 5 individual

⚠️ The contents of other directories will be automatically deleted after the container is closed! For more information, please visit https://hyperai.com/docs/concepts

Using command-line tools

By command bayes gear init Can initialize command-line tools in the container. For more information, please refer to https://hyperai.com/docs/cli/

(base) root@xushanchuan-fb075g25qn2k-main:/hyperai/home#

2. Launch a container gradio The service

Firstly, in "working space" Open a terminal in the middle, install gradio The dependence:

$ pip install gradio --user

Then create a app.py file. The content is as follows:

import gradio as gr


def greet(name):
return "Hello " + name + "!!"

demo = gr. Interface(fn=greet, inputs="text", outputs="text")
demo.launch()

Finally run python app.py Start service. You can see the following output:

$ python app.py

Running on local URL: http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.

You can see that the service has been successfully started. The access address is http://127.0.0.1:7860.

3. Adopt ssh tunnel Accessing remote ports

Use the following command to start ssh tunnel:

$ ssh -N -L localhost:7860:localhost:7860 root@ssh. HyperAI.com -p31552

among root@ssh. HyperAI.com -p31552 To maintain harmony "SSH visit" Consistently seen in the panel.

Then it can be accessed locally http://localhost:7860 Received service: