Using a Notebook Instance Remotely with SSH
This topic describes how to use CMD, MobaXterm, and local IDE to remotely log in to a notebook instance using SSH in a Windows environment.
Constraints
To connect to a notebook instance using SSH, pay attention to the following constraints:
- The local user key and permission must match.
- The local user key must be stored in the specified directory.
- Windows: C:\Users\{{user}}
- macOS/Linux: ~
On macOS and Linux, ~ indicates the home directory of the current user.
- The ma-user or root user in the remote image cannot be locked.
- Set the permission on the remote ~/.ssh directory to 750 or 755.
- The OpenSSH version on the local or remote server cannot be earlier than 8.0.
- Do not create more than 10 connections at the same time.
If SSH connection problems occur, rectify the fault by referring to Accessing a Notebook Instance Using SSH for Troubleshooting.
Prerequisites
- You have created an account key pair or private key pair on the DEW console and saved the key file to the directories below. For details, see Creating a Key Pair.
- Windows: C:\Users\{{user}}
- macOS/Linux: ~
If you choose I agree to host the private key of the key pair when creating a key pair, you can download the key again by clicking Export Private Key on the Account Key Pairs or Private Key Pairs page. If you do not choose this option, the key will only be available for download once, during creation. Keep your key safe.Figure 1 I agree to host the private key of the key pair
- You have enabled remote SSH for your notebook instance (select the created account key pair or private key pair). The instance must be in the Running state.
- For details about how to create a notebook instance, see Creating a Notebook Instance.
- For details about how to enable remote SSH for an existing notebook instance, see Enabling Remote SSH.
Figure 2 Creating a notebook instance for remote SSH development
- On the notebook instance details page, obtain the access address for remote SSH development from the basic information tab. For details, see Viewing details about a notebook instance. Figure 3 Instance details page
Remote SSH Development Address Description
The format of the remote SSH development address is as follows:
ssh -o StrictHostKeyChecking=no -i {key-file-name} {launch-user}@{domain-name} -p {port} Assume that the remote SSH development address is as follows: The key file name is KeyPair-1234-test.pem, ma-user is the startup user, authoring-ssh-modelarts-*****.huawei.com is the domain name, and 31092 is the port number.
ssh -o StrictHostKeyChecking=no -i KeyPair-1234-test.pem ma-user@authoring-ssh-modelarts-*****.huawei.com -p 31092
Method 1: Connecting to a Notebook Instance Using CMD
The following uses Windows as an example.
- Open CMD.
- Option A: Using the start menu
- Click the start button in the lower-left corner of your screen, or press the Windows key on your keyboard.
- Type CMD in the start menu and click Command Prompt.
- Option B: Using the run dialog box
- Press Windows + R on your keyboard to open the Run dialog box.
- Type CMD and press Enter or click OK.
- Option A: Using the start menu
- In CMD, navigate to the directory where the key is located, paste the remote SSH development address obtained from Prerequisites directly into the command window, and execute it to connect to the notebook instance.
As shown in the figure below, the appearance of the interactive interface indicates a successful connection.
Figure 4 Connecting to a notebook instance using CMD
Method 2: Connecting to a Notebook Instance Using MobaXterm
- Download and install MobaXterm.
- Open MobaXterm, click Session in the upper-left corner, and navigate to the SSH tab in the Session settings dialog box. Configure the Remote host, Username, Port, and Use private key, and click OK. Figure 5 Configuring a session
Obtain the remote SSH access address and the key file path from the Prerequisites. For example, the remote SSH access address is as follows. The following table describes the configuration.
ssh -o StrictHostKeyChecking=no -i KeyPair-1234-test.pem ma-user@authoring-ssh-modelarts-*****.huawei.com -p 31092
Table 1 Parameters Parameter
Description
Example Value
Basic SSH settings
Remote host
The address of the remote host, obtained from the remote SSH access address.
authoring-ssh-modelarts-*****.huawei.com
Username
The username used to connect to the remote host, obtained from the remote SSH access address.
ma-user
Port
The port number used to connect to the remote host, obtained from the remote SSH access address.
31092
Advanced SSH settings
Use private key
The full path of the key file. obtained from the Prerequisites.
C:\Users\***\KeyPair-1234-test.pem
As shown in the figure below, the appearance of the interactive interface indicates a successful connection.
Figure 6 Connecting to a notebook instance using MobaXterm
Method 3: Connecting to a Notebook Instance Using a Local IDE
You are advised to use VS Code as the local IDE to connect to your notebook instance.
- For details about the recommended VS Code version and constraints, see Connecting to a Notebook Instance Through VS Code.
- For details about how to use VS Code to connect to a notebook instance, see Connecting to a Notebook Instance Through VS Code with One Click.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot