# Access an Elastic Compute Instance

## Background Information

After creating elastic compute instances, you can remote control and manage them. Several remote access methods are listed below.

* **RDP (Remote Desktop Protocol)** \
  RDP is a remote desktop protocol commonly used for remote management of Windows operating systems. \
  You're recommended to remote connect to a Windows elastic compute via RDP.
* **SSH (Secure Shell)**\
  SSH is a command-line based remote management tool that uses a secure network protocol. SSH is widely used in UNIX-like operating systems, including Linux, BSD, and macOS.\
  You're recommended to use Terminal or Windows PowerShell to establish an SSH connection to non-Windows elastic compute instances.
* **RFB (Remote FrameBuffer)**\
  RFB is a protocol used for graphical remote management. VNC (Virtual Network Computing) is a common remote graphical management tool based on the RFB protocol used in UNIX-like operating systems. VNC login provides a graphical desktop environment, allowing you to interact with the instance visually. VNC protocol is also widely supported across multiple operating systems and platforms, which is more flexible and compatible.\
  You're recommended to remotely access and control the graphical interface of your elastic compute instances via VNC.

These protocols and tools offer various ways to remotely access and manage virtual machines. RDP provides a graphical interface for Windows virtual machines; SSH offers a command-line interface for remote management of UNIX-like virtual machines, and VNC enables graphical remote management of virtual machines regardless of operating systems.

Here we take a Linux instance (`Ubuntu-test`) and a Windows instance (`Windows-test`) as examples to demonstrate how to remote access them using you local computer.&#x20;

* `Ubuntu-test`\
  Default username: `ubuntu`\
  Password: `Test+123`
* `Windows-test`\
  Default username: `Admin`\
  Password: `Test+123`

<div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FtsCKlZYfRCgLqeihk6PA%2Fimage.png?alt=media&#x26;token=90dc1dd2-5def-458e-bb81-67e641f47c59" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

* <mark style="color:blue;">See</mark> [<mark style="color:purple;">**Create an Instance**</mark>](https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/create-an-instance) <mark style="color:blue;">for detailed information about how to create an elastic compute instance.</mark>
* <mark style="color:blue;">Your instance will be associated with one security group at least while being created. To remote access successfully, please ensure the security group allows traffic on the following ports: TCP 22 ( for SSH), TCP 3389 (for RDP), and ICMP port (used for network management and debugging).</mark>
* <mark style="color:blue;">The steps below may vary depending on the operating system and applications you are using. You may need to use different commands or tools to perform the same actions.</mark>
  {% endhint %}

## Access a Linux Instance via SSH

When you need to access a Linux instance, you can use SSH. Assume a macOS Terminal and a Windows PowerShell.

If you have deployed the SSH public key to your server, you can also using the SSH key for authentication without entering a password.

{% tabs %}
{% tab title="macOS client (Terminal)" %}

### Prerequisites

* Ensure the virtual machine has SSH enabled and is running.
* Obtain the public IP address of the virtual machine you want to access, that is a Linux instance (`Ubuntu-test`). You can find this information in the instance list page on zenConsole. Here is `113.31.99.141`.

### Procedures

1. Open the **Terminal** application on your macOS computer. You can find it in the **Applications** > **Utilities** folder, or you can use **Spotlight** to search for it.
2. In the **Terminal**, use the SSH command along with the IP address of the instance to establish a remote connection. The command syntax is as follows:

   ```bash
   ssh root@113.31.99.141
   ```
3. Press **Enter**, and **Terminal** will attempt to establish an SSH connection to the instance. If this is your first time connecting to the instance, you may be prompted to confirm the authenticity of the host by verifying its key fingerprint. Type `yes` to proceed.
4. After the SSH connection is successfully established, you will be prompted to enter the password for the selected username on the instance. Here provide `Test+123` and press **Enter**.
5. Once authenticated, you will have a **Terminal** session open on your macOS computer, but with the remote virtual machine's command-line interface. From here, you can execute commands and perform administrative tasks on the instance.
   {% endtab %}

{% tab title="Windows command line (PowerShell)" %}

### Prerequisites

* Ensure that the virtual machine has PowerShell Remoting enabled and is running. PowerShell Remoting is available by default on Windows operating systems.
* Obtain the public IP address of the virtual machine you want to access, that is a Linux instance (`Ubuntu-test`). You can find this information in the instance list page on zenConsole. Here is `113.31.99.141`.

### Procedures

1. Open the Windows **PowerShell** application on your Windows computer. You can do this by searching for "**PowerShell**" in the **Start** menu or by pressing `Win + X` and selecting **Windows PowerShell** or **Windows PowerShell (Admin)**.
2. In the **PowerShell** console, use the following command to establish a remote session with the instance:

   ```bash
   Enter-PSSession -ComputerName 113.31.99.141 -Credential root
   ```
3. Press **Enter**, and you will be prompted to enter the password for the selected username on the instance. Here provide `Test+123` and press **Enter**.
4. Once authenticated, you will have a **PowerShell** session open on your local computer, but with the remote virtual machine's command-line interface. From here, you can execute **PowerShell** commands and perform administrative tasks on the instance.
   {% endtab %}

{% tab title="SSH Key Pair" %}

### Prerequisites

Obtain the public IP address of the virtual machine you want to access, that is a Linux instance (`Ubuntu-test`). You can find this information in the instance list page on zenConsole. Here is `113.31.99.141`.

### Procedures

1. Generate an SSH key pair by running the following command on your local computer:

   ```bash
   ssh-keygen -t rsa -b 4096
   ```

   This will generate a 4096-bit RSA key pair, including a private key and a public key. By default, they will be saved in the `~/.ssh` directory.
2. Use the following command to retrieve the generated public key:

   ```bash
   cat ~/.ssh/id_rsa.pub
   ```

   This will display your public key. Copy it.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p><mark style="color:blue;"><strong>Note</strong></mark></p><p><mark style="color:blue;">For Windows operating system, use the <code>type</code> command to display the public key in the Command Prompt or PowerShell:</mark></p><pre class="language-bash"><code class="lang-bash">type %userprofile%\.ssh\id_rsa.pub
   </code></pre></div>
3. Use the SSH command along with the IP address to access the instance:

   ```bash
   ssh root@113.31.99.141
   ```
4. Press **Enter**. This will attempt to establish an SSH connection to the instance. If this is your first time connecting to the instance, you may be prompted to confirm the authenticity of the host by verifying its key fingerprint. Type `yes` to proceed.
5. After the SSH connection is successfully established, you will be prompted to enter the password for the selected username on the instance. Here provide `Test+123` and press **Enter**.
6. On the instance, open the `~/.ssh/authorized_keys` file (create it if it doesn't exist). You can open the file using the following command:

   ```bash
   nano ~/.ssh/authorized_keys
   ```

   Paste the previously retrieved public key into the file and save it.

### Result

You can now access the instance using the SSH key pair. Run the following command:

```bash
ssh -i ~/.ssh/id_rsa root@113.31.99.141
```

This will authenticate using the private key without requiring a password.
{% endtab %}
{% endtabs %}

## Access a Windows Instance via RDP

When you need to access a Windows instance, you're recommended to use RDP.&#x20;

### Prerequisites

* Ensure that the Windows instance is running and has RDP enabled. RDP is available by default on Windows operating systems.
* Obtain the public IP address of the instance, that is a Windows instance (`Windows-test`). You can find this information in the instance list page on zenConsole. Here is `113.31.99.255`.

### Procedures

1. Open the **Remote Desktop** client application on your local computer. This application is built into Windows, and you can find it by searching for "**Remote Desktop**" in the **Start** menu.
2. In the **Remote Desktop** client, enter the public IP address, that is `113.31.99.255`, of the instance in the "**Computer**" field.
3. Click **Connect** to initiate the connection.
4. If prompted, enter the credentials for the user account on the instance.\
   \- Default username: `Admin`\
   \- Password: `Test+123`
5. Once authenticated, the **Remote Desktop** client will establish a connection to the Windows instance. You will see the virtual machine's desktop displayed on your local computer.
6. You can now interact with the Windows instance as if you were sitting in front of it. You can run applications, access files, configure settings, and perform any other tasks you would normally do on a Windows desktop.

Remember to ensure that the necessary firewall rules are configured on both the virtual machine and your local machine to allow RDP connections.

## Access Your Instance via VNC

### Access a Linux Instance via VNC

You can remote access a Linux instance via VNC.

#### Prerequisites

You can remote access any virtual machine via VNC on zenConsole. Please obtain the public IP address of the virtual machine you want to access before remote access. Here we take the Linux instance (`Ubuntu-test`) as an example.

* Default username: `ubuntu`
* Password: `Test+123`

#### Procedures

1. Go to elastic compute instance list page, find the instance and click **Actions** > **VNC Access**.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FRUskHWtdHRJG5e714lx3%2Fimage.png?alt=media&#x26;token=44831f75-4f95-41ac-b4b6-bb900a823686" alt=""><figcaption></figcaption></figure></div>
2. Enter the default username: `ubuntu`, and press **Enter**. **Terminal** will attempt to establish an SSH connection.
3. Enter the password for the instance. Here provide `Test+123` and press **Enter**.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2F57K9Kr9btZ3fwT5x1LuA%2Fimage.png?alt=media&#x26;token=6b450674-0238-4845-9a38-81e415dc14ea" alt="" width="371"><figcaption></figcaption></figure></div>
4. Once authenticated, the VNC will establish a connection to the virtual machine. You should see the VM's desktop or graphical interface displayed in the VNC client window.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2F3CkTtPCCu8rHMQMYpwaL%2Fimage.png?alt=media&#x26;token=b66e5103-5e75-4d89-8a36-1962842093ca" alt="" width="563"><figcaption></figcaption></figure></div>
5. *<mark style="color:green;">(optional)</mark>* You can paste your code on the **Clipboard** and click <img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FOV96dPHuXzbTvdDZUEg2%2Fimage.png?alt=media&#x26;token=9ffd61d4-4aa6-418d-9d55-48a69fc05406" alt="" data-size="line"> to quick run your command.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2F1nurXeXieAqTAMLxvhJi%2Fimage.png?alt=media&#x26;token=26a9b2b9-7798-4e2a-93d2-f8c7a00f9207" alt="" width="366"><figcaption></figcaption></figure></div>

### Access a Windows Instance via VNC

You can remote access a Windows instance via VNC.

#### Prerequisites

You can remote access any virtual machine vis VNC on zenConsole. Please obtain the public IP address of the virtual machine you want to access before remote access. Here we take the Windows instance (`Windows-test`) as an example.

#### Procedures

1. Go to elastic compute instance list page, find the instance and click **Actions** > **VNC Access**.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FFMdj1woQeuQYvBMbpqvM%2Fimage.png?alt=media&#x26;token=2b3a9f3e-f9e3-4336-ac5a-36ce8aff835b" alt=""><figcaption></figcaption></figure></div>
2. Click <img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FOXzSAc9NoamPfiAy3AWn%2Fimage.png?alt=media&#x26;token=7ce44b68-fb99-4ac4-bb98-71a0740bbbf8" alt="" data-size="line"> on the left bar to unlock and click **Sign in**.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FETgsqee3510XTHQQ5B9r%2Fimage.png?alt=media&#x26;token=f3f229c5-c4c5-4ee1-b6f1-62d02b44f2d1" alt=""><figcaption></figcaption></figure></div>
3. Click **OK**, enter and confirm your new password to change the system-generated password.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FrmTFiqLqZuWCLHDNJKzY%2Fimage.png?alt=media&#x26;token=f01ad505-b4d5-415c-9094-a523698488ca" alt="" width="279"><figcaption></figcaption></figure></div>
4. Wait for your instance being accessed and then configure your local server.

   <div align="left"><figure><img src="https://3201622183-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9X3FDdkCL2HzhbPpPMFt%2Fuploads%2FWxcmQRzcoJjL88Yrgy9t%2Fimage.png?alt=media&#x26;token=11ed889c-69f3-473b-8de2-539539eccda0" alt=""><figcaption></figcaption></figure></div>

## Summary

The protocols and access methods mentioned above provide convenience and flexibility in different scenarios. You can choose the way that best suits your needs to remotely access and manage your virtual machines, whether it's using a graphical user interface or a command-line interface.&#x20;
