This topic describes how to connect to cloud phones by using Android Debug Bridge (ADB).
Prerequisites
A key pair is created or imported in the Cloud Phone console. The key pair is bound to a cloud phone. For more information, see Manage an ADB key pair.
To ensure a successful ADB connection from the on-premises environment to the cloud phone, the adbkey (private key) file is stored in one of the following directories based on the OS type:
macOS:
~/.androidWindows:
%USERPROFILE%\.android
The ADB process is restarted in the on-premises environment. To restart the ADB process, run the following commands:
adb kill-serveradb start-server
Procedure
If the instance group of the cloud phone to which you want to connect uses a shared network, you can establish ADB connections only over a virtual private cloud (VPC).
If the instance group of the cloud phone to which you want to connect uses a VPC, you can use the one-click ADB feature (recommended) or establish ADB connections over a VPC or the Internet.
One-click ADB
Prerequisites
Internet access has been enabled for the VPC network where the instance resides. For detailed instructions, see Manage networks.
Procedure
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
on the Instance page, find the target instance. In the Actions column, click the ⋮ icon and choose One-click ADB.
In the One-click ADB Connection panel, click Create ADB Connection.
NoteIf Internet access has not been enabled for your VPC network, click Activate Now in the dialog box that appears to enable it.

Wait until an ADB connection is established. You can click the icon to the right of ADB Connection Mode to copy the ADB connect command.

Next Step
The one-click ADB feature only establishes the ADB connection. You still need to properly configure your security groups to successfully connect to the instance. Ensure your security groups allow inbound access from source IP addresses to the cloud phone using the TCP protocol over port 5555. For detailed instructions, see ADB connection over the Internet.
ADB connection over a VPC
Connect to a cloud computer of the office network that resides in the specified VPC.
Run the following command to connect to the desired cloud phone:
adb connect <192.168.XX.XX>:5555NoteReplace
<192.168.XX.XX>with the private IP address of the cloud phone.
ADB connection over the Internet
If you want to access a cloud phone by using an ADB key pair from an on-premises device over the Internet, configure a Destination Network Address Translation (DNAT) entry and modify the security group settings.
Create an Internet NAT gateway in the VPC to which the desired cloud phone belongs. For more information, see How cloud phones access the Internet. If you already have an Internet NAT gateway, skip this step.
Create a DNAT entry for the Internet NAT gateway and configure a port mapping rule.
Log on to the NAT Gateway console.
On the Internet NAT Gateway page, find the desired Internet NAT gateway and click Configure DNAT in the Actions column.
On the DNAT Management tab, click Create DNAT Entry.
On the Create DNAT Entry page, configure the following parameters based on your business requirements:

Select EIP: Select an elastic IP address (EIP) and record it. The EIP is required when you run commands to connect to your cloud phone.
Select Private IP Address: Select Manual Input and enter the private IP address of the cloud phone.
Custom Port: Enter a public port and a private port that you want to map. Sample mapping ports:
1000:5555.
Modify the
policysecurity group of the elastic network interface (ENI) to allow traffic from the Internet to pass over port 5555.Log on to the ECS console.
In the left-side navigation pane, choose .
On the Elastic Network Interfaces page, find the ENI and click its ID. In the Basic Information section, find the first security group and click its ID.
NoteIn this example, the ENI has two security groups whose names are
vdaandpolicy. The rules in thepolicysecurity group must be modified. After you click the security group ID, you can view the security group name.
On the Inbound tab of the Security Group Details tab, click Add Rule to add the following rule:

Action: Allow.
Priority: 1.
Protocol Type: Custom TCP.
Port Range:
5555/5555.Authorization Object:
0.0.0.0/0.NoteThis rule allows traffic from all IP addresses to pass over port 5555. If you want to enhance network security, you can enter the public IP address of the on-premises device on which you run the ADB command.
Run the following command to connect to the desired cloud phone:
adb connect <Public IP address>:<DNAT public port>NoteReplace
<Public IP address>with the EIP associated with the DNAT entry and<DNAT public port>with the public port of the DNAT entry, which is port1000in this example.
