-
-
Save parkerlreed/ebc3c24a08b2d94dd510f502f3d5edd7 to your computer and use it in GitHub Desktop.
#!/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 [email protected]:"$pull_path" . | |
stop_sshd | |
;; | |
push) | |
push_path="$3" | |
init_sshd | |
mscp -P 8022 "$pull_path" [email protected]:"$push_path" | |
stop_sshd | |
;; | |
*) | |
echo "Invalid option" | |
;; | |
esac |
That solved one problem but stat: /sdcard/ Permission denied
is still an issue.
And you can list the SD card within termux directly?
Only thing I can think of is maybe try removing the trailing forward slash.
pull /sdcard
I can cd into sdcard and make it show the files. I tried what you suggested and it's just the same.
Ok this must be something new with Android 14. I'm seeing the same error here. I can list in Termux but not over the adb shell termux wrapper or SSH.
I'll let you know if I get it working.
In the meantime, the proper fix for path is \ escaping the $
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; bash'"```
Thanks for the script, transferring my photos/videos with 250MB/s now. Much better than mtp.
That solved one problem but
stat: /sdcard/ Permission denied
is still an issue.
But you did give Termux access to files right? :P
I've figured out the solution. The way to correctly allow permissions is to disable files permission, termux-setup-storage, enable files permission and it would work.
Could this be made to work with specific files in a folder? I kind of don't want to do a one large file transfer
Worst comes to worse. I guess it's not really needed since mine was all garbage too.