Question about Shell Access

I followed this documentation, but I met some problem. I didn’t see adbkey.pub under my path /home/[user]/.android/adbkey.pub. I only saw this two key under my path and they were all private key. How can I get the ADB public key? Help appreciated.
image

Hi @doom0831,

You can use ssh-keygen to generate the public key:

$ ssh-keygen -y -f adbkey > adbkey.pub   

Regards,
Axel

Hi @Axelm,

Thanks for your reply. I have my public key now, but I met another problem.

I have already entering public key in FreeFlight7 and I also connected to my drone.
When I used adb shell this command, I got this error. I found someone has the same problem with me, but the solution didn’t work on me. I also tried adb kill-server this command, but it didn’t work. Is there any solution? Help appreciated.
image

Hi @doom0831,

Could you provide the result of this command ? (when your computer si connected with the anafi ai) :

$ adb devices

Could you check whether the public key in the Freeflight application is correct?

Regards,
Axel

Hi @Axelm ,

Here is the result of this command. I’m curious why the first time I enter this adb connect anafi-ai.local:9050 command it fails, but the second time it connects successfully. It seems I get unauthorized. Is there any solution? Help appreciated.
image
The public key is correct, because when I take off the public key I can’t even connect.

This topic was automatically closed after 30 days. New replies are no longer allowed.

Hi @doom0831,

Really sorry for the delay, I think there was an error when you copied and pasted your key into FreeFlight. This is a python file that works with Olympe to put your key directly into the drone. Before running the python script, make sure the “Direct connection to the drone” parameter is enabled.

#!/usr/bin/env python3

import olympe
import sys
import time

from pathlib import Path

from olympe.messages.developer.Command import EnableShell
from olympe.messages.network.Command import SetDirectConnection

if len(sys.argv) > 1:
    ip = sys.argv[1]
else:
    ip = "192.168.42.1"

keyfile = Path("~/.android/adbkey.pub").expanduser()
key = keyfile.read_text().split(" ")[0]

drone = olympe.Drone(ip)

drone.connect()
drone(SetDirectConnection(mode="legacy")).wait()
drone(EnableShell(public_key=key))
time.sleep(3)
drone.disconnect()

Regards,
Axel

This topic was automatically opened after 12 days.