---
title: "Connect to a mobile farm device via ADB"
sidebar_label: "Connect to a device via ADB"
sidebar_position: 5
description: "How to connect to a mobile farm device using Android Debug Bridge (ADB)"
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Connect to a mobile farm device via ADB

Android Debug Bridge (ADB) — a tool that allows you to interact with Android OS devices via the command line interface. For example, you can:

* run shell commands and applications;
* remotely debug applications;
* transfer files between a mobile device and your computer;
* get logs;
* reboot the device;
* change device settings.

Learn more about the Android Debug Bridge tool in the [Android Debug Bridge (adb](https://developer.android.com/tools/adb)) documentation by Google.

1. [Install Android SDK Platform Tools](#install-android-sdk-platform-tools).
2. [Create an ADB key pair](#create-adb-keys).
3. [Add a public ADB key](#add-public-adb-key).
4. [Connect to the device via ADB](#connect-to-device-with-adb).

## 1. Install Android SDK Platform Tools \{#install-android-sdk-platform-tools}

Download the Android SDK Platform Tools distribution for your operating system on the [Android developer website by Google](https://developer.android.com/studio/releases/platform-tools).

## 2. Create an ADB key pair \{#create-adb-keys}

<Tabs queryString="create-adb-keys">
  <TabItem value="linux" default>
    <TabItemLabel>
      Linux
    </TabItemLabel>

    1. Open the CLI.

    2. Create an ADB key pair and place them in the folder where you want to store them:

       ```bash
       cd ~/.android/
       adb keygen adbkey
       adb pubkey ~/.android/adbkey > ~/.android/adbkey.pub
       ```

    3. Copy your public ADB key:

       ```bash
       xclip -sel clip < ~/.android/adbkey.pub
       ```
  </TabItem>

  <TabItem value="macos">
    <TabItemLabel>
      macOS
    </TabItemLabel>

    1. Open the CLI.

    2. Create an ADB key pair and place them in the folder where you want to store them:

       ```bash
       cd ~/.android/
       adb keygen adbkey
       adb pubkey ~/.android/adbkey > ~/.android/adbkey.pub
       ```

    3. Copy your public ADB key:

       ```bash
       pbcopy < ~/.android/adbkey.pub
       ```
  </TabItem>

  <TabItem value="windows">
    <TabItemLabel>
      Windows
    </TabItemLabel>

    1. Open the CLI.

    2. Create an ADB key pair and place them in the folder where you want to store them:

       ```bash
       cd %USERPROFILE%\.android\
       adb keygen adbkey
       adb pubkey %USERPROFILE%\.android\adbkey > %USERPROFILE%\.android\adbkey.pub
       ```

    3. Copy your public ADB key:

       ```bash
       type %USERPROFILE%\.android\adbkey.pub | clip
       ```
  </TabItem>
</Tabs>

## 3. Add a public ADB key \{#add-public-adb-key}

You can add a public ADB key to your profile or another user's profile and use it to [connect to mobile farm devices via ADB](#connect-to-device-with-adb).

The key will be available in all projects to which the user is added.

<Tabs queryString="add-public-adb-key">
  <TabItem value="own-profile" default>
    <TabItemLabel>
      To your profile
    </TabItemLabel>

    1. In the [control panel](https://my.selectel.ru/profile/access/adb-keys), in the upper right corner, open the menu (account number) and select **Profile**.
    2. Go to the **Access** section → **ADB Keys** tab.
    3. Click **Add key**.
    4. Enter a key name.
    5. Paste the public ADB key you copied when [creating the ADB key pair](#create-adb-keys) in step 3.
    6. Click **Add**.
  </TabItem>

  <TabItem value="other-user-profile">
    <TabItemLabel>
      To another user's profile
    </TabItemLabel>

    Keys for other users can be added by the [Account Owner](/access-control/user-types.mdx#account-owner) and users with the [`iam.admin`](/access-control/role-reference.mdx#iam-admin) role.

    1. In the [control panel](https://my.selectel.ru/iam/service-users), on the top menu, click **IAM**.

    2. Go to the section for the required [user type](/access-control/user-types.mdx):

       * **Panel users** — for users with access to the Control panel;
       * **Service users** — for users with programmatic access without access to the Control panel.

    3. Open the user page → **Access** tab.

    4. In the **ADB Keys** block, click **Add Key**.

    5. Enter a key name.

    6. Paste the public ADB key that you copied when [creating an ADB key pair](#create-adb-keys) in step 3.

    7. Click **Add**.
  </TabItem>
</Tabs>

## 4. Connect to the device via ADB \{#connect-to-device-with-adb}

1. In the [Control panel](https://my.selectel.ru/mobile-farm/), on the top menu, click **Products** and select **Mobile Farm**.

2. Go to the **Devices** section.

3. In the device row, click the device manufacturer and model.

4. Under the device name, copy the command to connect to the mobile farm device, for example:

   ```bash
   adb connect adb.mobfarm.selectel.ru:3094
   ```

   Where:

   * `adb.mobfarm.selectel.ru` — DNS address for connecting to mobile devices;
   * `3094` — example of a connection port.

5. Open the CLI.

6. Connect to the device by running the command you copied in step 4.

   Even if the connection is successful, you will see an authentication error in the response:

   ```bash
   failed to authenticate to adb.mobfarm.selectel.ru:3094
   ```

   Where:

   * `adb.mobfarm.selectel.ru` — DNS address for connecting to mobile devices;
   * `3094` — example of a connection port.

7. Ensure that the connection is established. To do this, request a list of connected devices:

   ```bash
   adb devices -l
   ```

   The response will list the connected devices. For example:

   ```bash
   List of devices attached
   adb.mobfarm.selectel.ru:3094 device product:AD8-RU model:TECNO_AD8 device:TECNO-AD8 transport_id:1
   ```

<Formbricks />
