Story
I like scrcpy. It allows me to cast my phone to computer and use it there thanks to cable technology (Wi-Fi works too). So, after hoping to Pop_OS! I reinstalled adb and scrcpy. But this time scrcpy didn’t work. Instead, it threw this error:
adb: error: failed to get feature set: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
ERROR: "adb push" returned with value 1
Easy way | Grant access using prompt on the phone
After enabling USB debugging in Developer options, connect phone to computer and run scrcpy. Phone should prompt you for granting access to computer. All you have to do is accept and connection will be granted ๐๏ธ
This prompt didn’t appear on my phone. As it turns out, that prompt doesn’t work as expected on some custom ROMs. After some digging online, I came across this answer on stack overflow. Which leads to a commit message for (new) adb authentication implemented in 2012. This prompt copies ~/.android/adbkey.pub on computer, $ADB_VENDOR_KEYS, to /data/misc/adb/adb_keys file in phone’s memory. Since prompt isn’t working for me, I have to add that key manually ๐๏ธ
Littler harder way: copy-paste on Termux as root
Since /data/misc/adb/adb_keys file is off-limits for the user. We need root privileges for this method.
- Copy
~/.android/adbkey.pubto phone’s memory - Open Termux and install sudo >
pkg install tsu - Navigate to where file
adbkey.pubis. I’m using a Redmi Note 4 and its/sdcarddirectory is used for.
File is at/sdcard/adbkey.pub, in my case, >cd /sdcard - Copy
adbkey.pubto/data/misc/adb/adb_keyswith sudo privileges >sudo cp adbkey.pub /data/misc/adb/adb_keys - Double check if content of
/data/misc/adb/adb_keyson phone and~/.android/adbkey.pubon computer are the same - Enjoy ๐๏ธ
Hard way: copy-paste using TWRP
This is the “no-root” hard method. You will still need root privileges to edit /data/misc/adb/adb_keys. If your phone isn’t rooted but has TWRP, GREAT. TWRP has root privileges and a file manager.
- Boot into TWRP by holding Vol+ and Power keys while the phone is turned off.
- Connect phone to computer.
- Copy
~/.android/adbkey.pubto phone’s memory - Go to Advanced > File manager.
- Navigate to where
adbkey.pubwas copied to. I am using Redmi Note 4 and MTP connects to/sdcardon this device. - Copy
adbkey.pubto/data/misc/adb/adb_keys. - Delete
adb_keysas the old one wasn’t working. - Rename
adbkey.pubtoabd_keys. - Double check if content of
/data/misc/adb/adb_keyson phone and~/.android/adbkey.pubon computer are the same. - Enjoy ๐๏ธ

It was a little annoying adventure for me to find where the adbkey.pub was supposed to go. I am not intimidated with having to do that this manually. I was annoyed that this information isn’t out there in Android documentations and requires reading answers from 2014 on stack overflow.
I hope this guide was helpful to you ๐๏ธ
Day 7 of #100DaysToOffload
Comments
Toot on this thread to comment. This blog is a static site. Comments won’t appear here.