[SOLVED] ADB 'unauthorized', no RSA prompt, and no 'Revoke USB debugging' option

Search This thread

NFSP G35

Senior Member
Feb 28, 2012
363
208
After fighting with this for nearly a month and reading dozens of threads on xda, stack-overflow, etc... I finally figured out this issue, so I'm putting it here in hopes it saves someone else the frustration.

The issue presented itself on my HTC One (M8) running the ViperOne 6.1.0 ROM.
I'm putting this thread in the general section though since I've seen many people with very similar, if not the same issues on a wide variety of devices.

I believe the root cause of my particular issue may be the way HTC sets their devices to simply allow all debugging without authorization if the phones are s-off.
Mine is still s-on, but I have another M8 that's s-off with the exact same ROM as well as an s-off M9, and both of them go straight into debugging, no questions asked, no prompt.
I'm wondering if maybe the ROM was developed using a developer version of the phone and is just missing the prompt, or something similar, but this is just conjecture.

The basic problem was that, when I tried to connect ADB, it showed the phone as "unauthorized" and no matter what I did, the prompt would not come up on the phone to allow debugging.
Also of note, I was missing the "Revoke USB debugging authorizations" menu item entirely (I could search for it, but it wasn't actually there in the menu)
I tried many different combinations of changing drivers, USB modes, enabling/disabling debugging, different machines, deleting the public and private keys for ADB on the computer, etc... all to no avail.

Finally, after much research and testing, I found this comment on stack-overflow and figured out how to manually authorize keys.

Note: This will require root, a custom recovery, or some way of writing the the system partition (I used TWRP at first, then TerminalEmulator later)

The key was to understand what clicking the dialog to 'always allow' a machine actually does.
When you click to always allow, android appends the public key from ADB on the computer into a specific file on the phone.
Since my phone wouldn't connect in the first place though, I didn't have that file or understand the format, etc...
The file is called adb_keys, it is a file (not folder) which is located at: /data/misc/adb/
The format of this file is one public key per line.

Thus, there are a couple of ways to go about manually authorizing a machine for debugging.

First, manually building the adb_keys file. (This is what I did at first)
Second, copying an existing adb_keys file from another device (Which doesn't need root)

For manually building the adb_keys file, the first step is to find the public key on the computer.
For me (Windows 10) it was located at C:\Users\<my profile>\.android\adbkey.pub
For Linux and OSX, I believe it is at: ~/.android/adbkey.pub
If you only need to authorize one computer:
Simply copy the adbkey.pub onto the device location: /data/misc/adb/ and rename it from adbkey.pub to adb_keys
chmod 0644 and then reboot.

Now, the phone should accept debugging from the computer just as though you clicked the dialog.

If you need to authorize several computers...
As mentioned, the /data/misc/adb/adb_keys file is actually a list of all the keys which have debugging permissions, one key per line.
First, collect the adbkey.pub files from each computer you want to authorize.
Then, using a text editor which supports linux style line breaks (Notepad++ if on windows) simply create your own adb_keys file by appending the contents of each adbkey.pub file, putting a line break between each key
Now save the adb_keys file you just created, and put it on the phone's /data/misc/adb/ folder using whatever method you prefer, and chmod 0644

If you need to revoke debugging permissions, (like the menu option, if the menu option is missing)
Simply delete /data/misc/adb/adb_keys

And finally,
If you have access to another device (does not have to be rooted) and want to replicate its debugging permissions
Plug the 'donor' device into the computer first, then issue:
adb pull /data/misc/adb/adb_keys c:\temp\adb_keys
(Or replace "C:\temp\adb_keys" with whatever file path works for you)
Then, copy the file to the 'target' device in the same location (/data/misc/adb/adb_keys) and chmod 0644

I've tested all of these methods and they worked well.
In the end, I used the last method since my tablet had all the debugging permissions I wanted on my phone.
 

artician

Senior Member
Dec 29, 2015
50
5
Hi, I ran into this issue with my Moto G5 plus. The only difference is that I'm not missing the Revoke Auth option, even though using it does nothing for me, and I still fail to get the Authorization popup when connecting via USB/using ADB.
I tried the above method of copying the adbkey.pub file to my device directory, renaming, etc. I am doing something wrong and would like a hint.

I copied the adb_keys via Windows Explorer to my devices root directory. There was a /data/ directory, but only Titanium Backup had a subdirectory within, so I created .../misc/adb/, and placed the adb_keys file there.

I rebooted to the TWRP recovery Terminal, and navigated to the /data/misc/adb directory. I ran chmod, and the system could not find the file specified. Listing directory contents also showed the directory to be empty (yet when viewed in Explorer or LineageOS, it's visible).

Did I place the keys file in the wrong place?
 

misuvi

New member
Oct 24, 2018
3
0
Inception

I was trying to Copy one donor device's Adb key file to my broken android phone to mirror it on my PC, Following the guide of another post, and somehow i stumbled across this post, after failing to copy from Donor device. Now i managed to copy the adb_key from Donor device but LOL my broken Android device is Unauthorized. What should i do? IS THERE ANY SOLUTION?
 

NFSP G35

Senior Member
Feb 28, 2012
363
208
I was trying to Copy one donor device's Adb key file to my broken android phone to mirror it on my PC, Following the guide of another post, and somehow i stumbled across this post, after failing to copy from Donor device. Now i managed to copy the adb_key from Donor device but LOL my broken Android device is Unauthorized. What should i do? IS THERE ANY SOLUTION?

Do you have any way of writing to the /data/misc/adb/adb_keys file on the broken device?
 

misuvi

New member
Oct 24, 2018
3
0
I think i just did!

Do you have any way of writing to the /data/misc/adb/adb_keys file on the broken device?
I rebooted into recovery mode, copied, but still the mirroring application is not working, still prompting for allowing USB debugging. Now i connected the donor device on That mirroring application and Saved the RSA of Mirroring application, and going once again. Wish me good luck :)
 

NFSP G35

Senior Member
Feb 28, 2012
363
208
I rebooted into recovery mode, copied, but still the mirroring application is not working, still prompting for allowing USB debugging. Now i connected the donor device on That mirroring application and Saved the RSA of Mirroring application, and going once again. Wish me good luck :)

Well, don't forget to post back if it worked :good:
 

misuvi

New member
Oct 24, 2018
3
0
Guess I did i good job

Well, don't forget to post back if it worked :good:

Well it didn't work since the Adb server of Cmd and mirroring application were different, so i searched for another application which has same server as Cmd, and luckily i found a great software by Genymobile, named scrcpy, from github, just one click on scrcpy-noconsole and boom? Thanks for all the help.
 

NFSP G35

Senior Member
Feb 28, 2012
363
208
Well it didn't work since the Adb server of Cmd and mirroring application were different, so i searched for another application which has same server as Cmd, and luckily i found a great software by Genymobile, named scrcpy, from github, just one click on scrcpy-noconsole and boom Thanks for all the help.

Cool, glad to help.
For a while, I looked for ways to get around this from a different angle (for example, making the keys match on the ADB server side) but I ran into some issues and ended up getting what I needed via the steps in the OP.

Glad you got it working though!
 
  • Like
Reactions: misuvi

jjohst

New member
Feb 23, 2016
2
2
"And finally,"...you should have led with that ;)

I cannot thank you enough! Other proposed solutions to this hellish problem made my head hurt. This was beautifully simple - copy file from the working device onto non-working, change permissions and BOOM! It works.

Thanks again, you're awesome!
 
  • Like
Reactions: NFSP G35 and misuvi

Aeroxia

New member
Nov 17, 2019
1
0
Oh my god, it's not a folder! Thank you so much! I was about to give up, this was driving me totally crazy. Everywhere on the internet they just keep repeating the same advice that did nothing, I actually created that as a folder and no wonder it wasn't working.

I still can't believe it's working now, ahhh...
 

Bungle2000

Member
Jan 19, 2013
18
0
I am trying to use the 'copy keys file from another device' method.
I've copied the adb_keys file to my PC.
Now, how do I copy that file from the PC to the data folder?
adb won't allow it as it's not authorised, what am I missing?
Thank you in advance for your help!
 

NFSP G35

Senior Member
Feb 28, 2012
363
208
I am trying to use the 'copy keys file from another device' method.
I've copied the adb_keys file to my PC.
Now, how do I copy that file from the PC to the data folder?
adb won't allow it as it's not authorised, what am I missing?
Thank you in advance for your help!

You can't copy to the device through ADB until you get ADB authorized... that's the whole point... you have to use some other method to get the file there.
I used TWRP custom recovery to copy the file from an external SD card the folder.
If you don't have an external SD card, use USB MTP/PTP, Mass Storage, a USB OTG adapter and thumb drive... if you desperate, zip the file and email it to yourself... pretty much endless methods of actually getting the file onto the phone somehow.
But you'll need root (or a custom recovery) to copy the file from wherever it is on the device to the correct location (/data/misc/adb/adb_keys)
You could potentially use several methods, for example you could use terminal emulator or a root file explorer to get the file to the correct folder.
 

Bungle2000

Member
Jan 19, 2013
18
0
You can't copy to the device through ADB until you get ADB authorized... that's the whole point... you have to use some other method to get the file there.
I used TWRP custom recovery to copy the file from an external SD card the folder.
If you don't have an external SD card, use USB MTP/PTP, Mass Storage, a USB OTG adapter and thumb drive... if you desperate, zip the file and email it to yourself... pretty much endless methods of actually getting the file onto the phone somehow.
But you'll need root (or a custom recovery) to copy the file from wherever it is on the device to the correct location (/data/misc/adb/adb_keys)
You could potentially use several methods, for example you could use terminal emulator or a root file explorer to get the file to the correct folder.

Hey NFSP G35, thank you for the reply!
I figured there was something I was missing, I just don't know the steps to do it right.

I have a Moto X Play that has a broken screen, so no display, and does not accept touch input.
It powers on and is working as it was before the screen broke as far as I can tell, so I'm trying to connect it up to the PC to get all the data off it.
However, before it broke, something happened with the software that meant Google Play disappeared.

The device is stock Motorola device, so not rooted, no TWRP etc. USB debugging is enabled but not authorised.

What would you recommend is the best way to get the adb_keys onto the phone given the issues above?

Your help is greatly appreciated!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 35
    After fighting with this for nearly a month and reading dozens of threads on xda, stack-overflow, etc... I finally figured out this issue, so I'm putting it here in hopes it saves someone else the frustration.

    The issue presented itself on my HTC One (M8) running the ViperOne 6.1.0 ROM.
    I'm putting this thread in the general section though since I've seen many people with very similar, if not the same issues on a wide variety of devices.

    I believe the root cause of my particular issue may be the way HTC sets their devices to simply allow all debugging without authorization if the phones are s-off.
    Mine is still s-on, but I have another M8 that's s-off with the exact same ROM as well as an s-off M9, and both of them go straight into debugging, no questions asked, no prompt.
    I'm wondering if maybe the ROM was developed using a developer version of the phone and is just missing the prompt, or something similar, but this is just conjecture.

    The basic problem was that, when I tried to connect ADB, it showed the phone as "unauthorized" and no matter what I did, the prompt would not come up on the phone to allow debugging.
    Also of note, I was missing the "Revoke USB debugging authorizations" menu item entirely (I could search for it, but it wasn't actually there in the menu)
    I tried many different combinations of changing drivers, USB modes, enabling/disabling debugging, different machines, deleting the public and private keys for ADB on the computer, etc... all to no avail.

    Finally, after much research and testing, I found this comment on stack-overflow and figured out how to manually authorize keys.

    Note: This will require root, a custom recovery, or some way of writing the the system partition (I used TWRP at first, then TerminalEmulator later)

    The key was to understand what clicking the dialog to 'always allow' a machine actually does.
    When you click to always allow, android appends the public key from ADB on the computer into a specific file on the phone.
    Since my phone wouldn't connect in the first place though, I didn't have that file or understand the format, etc...
    The file is called adb_keys, it is a file (not folder) which is located at: /data/misc/adb/
    The format of this file is one public key per line.

    Thus, there are a couple of ways to go about manually authorizing a machine for debugging.

    First, manually building the adb_keys file. (This is what I did at first)
    Second, copying an existing adb_keys file from another device (Which doesn't need root)

    For manually building the adb_keys file, the first step is to find the public key on the computer.
    For me (Windows 10) it was located at C:\Users\<my profile>\.android\adbkey.pub
    For Linux and OSX, I believe it is at: ~/.android/adbkey.pub
    If you only need to authorize one computer:
    Simply copy the adbkey.pub onto the device location: /data/misc/adb/ and rename it from adbkey.pub to adb_keys
    chmod 0644 and then reboot.

    Now, the phone should accept debugging from the computer just as though you clicked the dialog.

    If you need to authorize several computers...
    As mentioned, the /data/misc/adb/adb_keys file is actually a list of all the keys which have debugging permissions, one key per line.
    First, collect the adbkey.pub files from each computer you want to authorize.
    Then, using a text editor which supports linux style line breaks (Notepad++ if on windows) simply create your own adb_keys file by appending the contents of each adbkey.pub file, putting a line break between each key
    Now save the adb_keys file you just created, and put it on the phone's /data/misc/adb/ folder using whatever method you prefer, and chmod 0644

    If you need to revoke debugging permissions, (like the menu option, if the menu option is missing)
    Simply delete /data/misc/adb/adb_keys

    And finally,
    If you have access to another device (does not have to be rooted) and want to replicate its debugging permissions
    Plug the 'donor' device into the computer first, then issue:
    adb pull /data/misc/adb/adb_keys c:\temp\adb_keys
    (Or replace "C:\temp\adb_keys" with whatever file path works for you)
    Then, copy the file to the 'target' device in the same location (/data/misc/adb/adb_keys) and chmod 0644

    I've tested all of these methods and they worked well.
    In the end, I used the last method since my tablet had all the debugging permissions I wanted on my phone.
    2
    For manually building the adb_keys file, the first step is to find the public key on the computer.
    For me (Windows 10) it was located at C:\Users\<my profile>\.android\adbkey.pub
    ...
    If you only need to authorize one computer:
    Simply copy the adbkey.pub (Windows 10 / C:\Users\<my profile>\.android\adbkey.pub) onto the device location* : /data/misc/adb/ and rename it from adbkey.pub to adb_keys chmod 0644 and then reboot.
    *(into the recovery with TWRP FileManager)

    I had this problem on Samsung Galaxy S7 with the Havoc-OS-v3.7 ROM.
    Your solution worked perfectly.
    Thanks !
    2
    "And finally,"...you should have led with that ;)

    I cannot thank you enough! Other proposed solutions to this hellish problem made my head hurt. This was beautifully simple - copy file from the working device onto non-working, change permissions and BOOM! It works.

    Thanks again, you're awesome!
    2
    Happy to help!
    2
    This still works today, I had this issue with an android tv box running Bliss Os 11.14 x86_x64. Worked like a charm. Both using adb on my linux system and adblink.