Configure and connect to a Cloud Phone instance by using Android Debug Bridge (ADB).
Prerequisites
-
Create or import a key pair in the Cloud Phone console and bind the key pair to the target Cloud Phone instance. For more information, see Manage key pairs.
-
Save the private key file
adbkeyto the following directory to enable ADB logon.-
Directory on macOS:
~/.android -
Directory on Windows:
%USERPROFILE%\.android
-
-
Run the following commands to restart the local ADB service.
adb kill-serveradb start-server
Procedure
-
If your Cloud Phone instance is in an instance group that uses a Shared Network, only an ADB connection over a VPC is supported.
-
If your Cloud Phone instance is in an instance group that uses a VPC, you can use one-click ADB (recommended), an ADB connection over a VPC, or an ADB connection over the Internet.
One-click ADB (recommended)
Prerequisites
Internet access must be enabled for the instance's VPC network. For more information, see Manage Internet access for a VPC network.
Procedure
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
-
On the Instance page, find the target instance, click the ⋮ icon in the Actions column, and select One-click ADB.
-
In the One-click ADB Connection panel, click Create ADB Connection.
NoteIf the VPC network does not have Internet access enabled, click Activate Now in the dialog box that appears.
-
After a moment, the ADB connection is automatically created. Click the copy icon next to ADB Connection Mode to copy the command.
What to do next
One-click ADB establishes the connection but does not configure security groups. Allow inbound TCP traffic on port 5555 from your source address to the Cloud Phone instance. For more information, see ADB connection over the Internet.
ADB connection over a VPC
-
Connect to an Elastic Desktop Service (EDS) instance in the same VPC as your Cloud Phone instance.
-
Run the following command to connect to the Cloud Phone instance.
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
To connect to a Cloud Phone instance over the Internet by using ADB, create a DNAT entry and configure the security group.
-
Create an Internet NAT gateway in the Cloud Phone instance's VPC. For more information, see Enable Internet access for a Cloud Phone instance. If an Internet NAT gateway already exists, skip this step.
-
Create a DNAT entry on the Internet NAT gateway with a port mapping rule.
-
Log on to the NAT gateway console.
-
On the NAT Gateway page, find the target Internet NAT gateway instance, 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:
-
Select EIP: Select an available elastic IP address (EIP). Note this EIP for use when connecting.
-
Select private IP address: Select Manual Input and enter the private IP address of the Cloud Phone instance.
-
Specific port: Enter the public and private ports to map, for example
1000:5555.
-
-
-
Modify the
policysecurity group rules to open port 5555 for public access.-
Log on to the ECS console.
-
In the left-side navigation pane, choose Network & security > Elastic network interfaces.
-
On the Elastic network card page, click the ID of the target elastic network interface. Then, in the Basic Information section, click the ID of the first security group.
NoteThe elastic network interface has two security groups:
vdaandpolicy. Modify thepolicygroup. Click a security group ID to view its name. -
On the security group details page, click the Inbound tab, click Add rule, and configure the following settings:
-
Action: Allow
-
Priority: 1
-
Protocol type: Custom TCP
-
Port range:
5555/5555 -
Source:
0.0.0.0/0NoteThis allows all IP addresses to access port 5555. For better security, specify the public IP address of your local device.
-
-
-
Run the following command to connect to the Cloud Phone instance:
adb connect <Public IP>:<DNAT public port>NoteReplace
<PublicIPAddress>with the EIP of the DNAT entry and<DNATPublicPort>with the public port. In this example, the port is1000.