Prepare an ADB key pair and attach it to a Cloud Phone instance so that you can connect securely through ADB.
Prepare a key pair
You can create a key pair in the console or generate one locally with ADB and import it.
Create a key pair
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
-
In the upper-left corner of the Secret page, click Create Key Pair.
-
In the Create Key Pair dialog box, enter a name for the key pair and click OK.
NoteThe name must be 2 to 128 characters long, cannot start with a special character or digit, and can only contain periods (.), underscores (_), hyphens (-), and colons (:).
ImportantYour browser automatically downloads the adbkey file when you create a key pair. Save this file securely. Lost files cannot be recovered; you must create a new key pair.
Import a key pair
-
Generate a key pair locally with ADB.
Windows
-
Download the ADB toolkit for Windows and extract the package.
-
Open Command Prompt and navigate to the ADB toolkit directory.
NoteReplace the sample path with the actual directory path.
cd C:\Users\Administrator\Downloads\platform-tools -
Generate a key pair.
adb devicesNoteTo regenerate a deleted key pair, run
adb kill-serverand then runadb devices.By default, ADB stores the key pair in the
%USERPROFILE%\.androiddirectory as two files: adbkey (private key) and adbkey.pub (public key). -
Open
adbkey.puband copy the public key.
macOS
-
Download the ADB toolkit for macOS and extract the package.
-
Open Terminal and navigate to the ADB toolkit directory.
NoteReplace the sample path with the actual directory path.
cd downloads/platform-tools -
Generate a key pair.
./adb devicesNoteTo regenerate a deleted key pair, run
./adb kill-serverand then run./adb devices.By default, ADB stores the key pair in the
~/.androiddirectory as two files: adbkey (private key) and adbkey.pub (public key). -
Open
adbkey.puband copy the public key.
Linux
-
Log on to your Linux server.
-
Install the ADB toolkit.
sudo apt-get install adb -
Verify the installation.
adb versionExpected output:
[root@iZbp1dtvts0j8lbejlz**** ~]# adb version Android Debug Bridge version 1.0.39 -
Generate a key pair.
adb devicesNoteTo regenerate a deleted key pair, run
adb kill-serverand then runadb devices.By default, ADB stores the key pair as two files, adbkey (private key) and adbkey.pub (public key), in the
~.androiddirectory. -
View and copy the public key from
adbkey.pub.cat ~/.android/adbkey.pub
-
-
Import the public key into the console.
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
-
In the upper-left corner of the Secret page, click Import Key Pair.
-
In the Import Key Pair dialog box, enter a name for the key pair, paste the public key content that you copied in the previous step, and then click OK.
NoteThe name must be 2 to 128 characters long, cannot start with a special character or digit, and can only contain periods (.), underscores (_), hyphens (-), and colons (:).
Attach a key pair
Prerequisites
The Cloud Phone instance must be in the Running state.
Procedure
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
-
On the Secret page, find the target key pair and click Attach Key Pair in the Actions column.
-
In the Attach Key Pair dialog box, select the target Cloud Phone instance from the Instances list on the left, click the arrow icon to move it to the list on the right, and then click Bind.
-
Save the private key file
adbkeyto the correct local directory to enable ADB connections.-
Windows:
%USERPROFILE%\.androiddirectory. -
macOS:
~/.androiddirectory. -
Linux:
~.androiddirectory.
Restart the local ADB service.
-
Windows:
adb kill-server -
macOS:
./adb kill-server -
Linux:
adb kill-server
-
Unbind a key pair
Prerequisites
The Cloud Phone instance must be in the Running state.
Procedure
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
-
On the Secret page, find the target key pair and click Unbind Key Pair in the Actions column.
-
In the Unbind Key Pair dialog box, select the target Cloud Phone instance from the Instances list on the left, click the arrow icon to move it to the list on the right, and then click Disassociate.
After unbinding a key pair, existing ADB sessions are not immediately disconnected, but new connection attempts will fail.
Delete a key pair
Prerequisites
The key pair must not be attached to any Cloud Phone instances.
Procedure
Log on to the Cloud Phone console.
In the left-side navigation pane, choose .
-
On the Secret page, find the target key pair and click Delete in the Actions column.
-
In the confirmation dialog box, click OK.
WarningThis action is irreversible; the key pair cannot be recovered once deleted. Proceed with caution.
Next steps
To connect to a Cloud Phone instance through ADB, follow the instructions in Connect to a Cloud Phone instance by using ADB.