Last active
November 10, 2024 06:23
-
-
Save gturi/d88f628bc7f53cac273b51bf93b25408 to your computer and use it in GitHub Desktop.
Revisions
-
gturi revised this gist
Aug 16, 2024 . 1 changed file with 14 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ ## Install scrcpy Scrcpy allows to send keyboard input to the device, its installation is recommended since typing commands in the terminal from Android's keyboard it is quite uncomfortable: ```bash scrcpy -K @@ -17,7 +17,7 @@ scrcpy -K - run `ssh-keygen -A` - run `termux-setup-storage` - this will make the app ask for storage permission - run `sshd` - run `ifconfig` to know you IP address - look at `inet` field that looks like 192.168.X.Y ## Test ssh connection @@ -37,9 +37,16 @@ cd /storage/emulated/0 ls ``` ## Mount android ### With rclone Run `rclone config` and select `sftp` option and follow the guided setup. ```bash rclone config ``` Performing a minimal setup will produce something like this at `$HOME/.config/rclone`: @@ -66,7 +73,9 @@ sudo chown "$user:$user" "$mount_point" rclone mount android-ssh:$android_dir "$mount_point" --sftp-ask-password ``` ### With sshfs (deprecated) Unfortunately sshfs is no longer maintained, but the setup script is still left for reference. ```bash android_dir=/storage/emulated/0 -
gturi revised this gist
Apr 26, 2023 . 1 changed file with 31 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Mount an Android device on your pc filesystem over ssh ## Install scrcpy Scrcpy allows to send keyboard input to the device, its installation is recommended since typing commands in the terminal from Android's keyboard it is quite unconfortable: @@ -37,6 +37,35 @@ cd /storage/emulated/0 ls ``` ## Mount android with rclone Run rclone config and select sftp option and follow the guided setup. Performing a minimal setup will produce something like this at `$HOME/.config/rclone`: ``` [ssh-connection-name] type = sftp host = $android_ip port = $port ``` By default rclone will attempt to connect using `ssh-agent`. To connect using a password use `--sftp-ask-password` flag: ```bash android_dir=/storage/emulated/0 mount_point=/mnt/android-device curr_user="$(whoami)" id "$curr_user" sudo mkdir "$mount_point" sudo chown "$user:$user" "$mount_point" rclone mount android-ssh:$android_dir "$mount_point" --sftp-ask-password ``` ## Mount android with sshfs ```bash @@ -69,7 +98,7 @@ If you want to specify a custom ssh config: -F /path/to/.ssh/config ``` ## Stop Android ssh server ```bash pkill sshd -
gturi revised this gist
Apr 25, 2023 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -47,14 +47,14 @@ user="$(whoami)" id "$user" sudo mkdir "$mount_point" sudo chown "$user:$user" "$mount_point" sshfs \ -o idmap="$user" \ -p $port \ "$android_ip:$android_dir" \ "$mount_point" ``` If you need to troubleshoot `sshfs` connection you can add the following options: @@ -78,7 +78,7 @@ pkill sshd ## Unmount directory ```bash fusermount -u "$mount_point" sudo umount "$mount_point" sudo rmdir "$mount_point" ``` -
gturi revised this gist
Mar 29, 2023 . 1 changed file with 14 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,13 @@ # Mount an Android device on your pc filesystem over ssh ### Install scrcpy Scrcpy allows to send keyboard input to the device, its installation is recommended since typing commands in the terminal from Android's keyboard it is quite unconfortable: ```bash scrcpy -K ``` ## Install Termux and setup openssh server - Install Termux from Github (or F-Droid) on the phone you want to SSH into. Don't use the Play Store version, it doesn't work @@ -11,6 +19,7 @@ - run `sshd` - run `ifconfig` to know you ip address - look at inet field that looks like 192.168.X.Y ## Test ssh connection ```bash @@ -34,13 +43,15 @@ ls android_dir=/storage/emulated/0 mount_point=/mnt/android-device user="$(whoami)" id "$user" sudo mkdir $mount_point sudo chown "$user:$user" $mount_point sshfs \ -o idmap="$user" \ -p $port \ $android_ip:$android_dir \ $mount_point -
gturi revised this gist
Mar 29, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -31,15 +31,15 @@ ls ## Mount android with sshfs ```bash android_dir=/storage/emulated/0 mount_point=/mnt/android-device id $(whoami) sudo mkdir $mount_point sudo chown $(whoami):$(whoami) $mount_point sshfs \ -o idmap=$(whoami) \ -p $port \ $android_ip:$android_dir \ -
gturi created this gist
Mar 29, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ # Mount an Android device on your pc filesystem over ssh ## Install Termux and setup openssh server - Install Termux from Github (or F-Droid) on the phone you want to SSH into. Don't use the Play Store version, it doesn't work - run `pkg update` and `pkg upgrade` - run `passwd` and set up a password - run `pkg install openssh` - run `ssh-keygen -A` - run `termux-setup-storage` - this will make the app ask for storage permission - run `sshd` - run `ifconfig` to know you ip address - look at inet field that looks like 192.168.X.Y ## Test ssh connection ```bash port=8022 android_ip=192.168.X.Y ssh $android_ip -p $port ``` The last command will prompt to digit the password you have previously entered. Usually ssh specifies a username (username@$server_ip), if your ssh client doesn't allow you to not enter a username, just use a blank space or asterisk. Once connected, you can display your device internal directory tree as follows: ```bash cd /storage/emulated/0 ls ``` ## Mount android with sshfs ```bash android_dir=/storage/emulated/0/Download mount_point=/mnt/android-device id $(whoami) sudo mkdir $mount_point sudo chown $(whoami):$(whoami) $mount_point sudo sshfs \ -o idmap=$(whoami) \ -p $port \ $android_ip:$android_dir \ $mount_point ``` If you need to troubleshoot `sshfs` connection you can add the following options: ```bash -o debug,sshfs_debug,loglevel=debug ``` If you want to specify a custom ssh config: ```bash -F /path/to/.ssh/config ``` ## Stop ssh server ```bash pkill sshd ``` ## Unmount directory ```bash fusermount -u $mount_point sudo umount $mount_point sudo rmdir $mount_point ```