Last active
June 13, 2024 17:00
-
-
Save parkerlreed/ebc3c24a08b2d94dd510f502f3d5edd7 to your computer and use it in GitHub Desktop.
betteradbcopy - Multi-threaded SCP to/from Android device over USB/WiFi with Termux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure to have OpenSSH setup in Termux as well as setting a password with `passwd` | |
# Requires https://github.com/upa/mscp and adb platform tools on your local machine | |
init_sshd() { | |
adb shell -t "run-as com.termux files/usr/bin/bash -lic 'export PATH=/data/data/com.termux/files/usr/bin:$PATH; export LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so; sshd'" | |
adb forward tcp:8022 tcp:8022; | |
} | |
stop_sshd() { | |
adb shell -t "run-as com.termux files/usr/bin/bash -lic 'export PATH=/data/data/com.termux/files/usr/bin:$PATH; export LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so; killall sshd'" | |
adb forward --remove tcp:8022; | |
} | |
pull_path="$2" | |
case "$1" in | |
pull) | |
init_sshd | |
mscp -P 8022 parker@127.0.0.1:"$pull_path" . | |
stop_sshd | |
;; | |
push) | |
push_path="$3" | |
init_sshd | |
mscp -P 8022 "$pull_path" parker@127.0.0.1:"$push_path" | |
stop_sshd | |
;; | |
*) | |
echo "Invalid option" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the meantime, the proper fix for path is \ escaping the $