1

I am trying to use rsync to transfer some files from my Android phone (Samsung Galaxy S10+ / Android V10) to my local machine (OSX / Mojave).

I did the following:

  1. Installed SSH/SFTP server on my Android device and started the server

  2. Verified that I am able to ssh into the phone (although it logs me in as user u0_a312 and not my_user?)

$ ssh [email protected] -p 2222

The authenticity of host '[192.168.0.16]:2222 ([192.168.0.16]:2222)' can't be established. RSA key fingerprint is SHA256:3mNL574rJyHCOGm1e7Upx4NHXMg/YnJJzq+jXhdQQxI. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[192.168.0.16]:2222' (RSA) to the list of known hosts. Password authentication Password: :/ $ whoami u0_a312

  1. Attempted to run rsync from my local OSX machine to copy remote Android files to my laptop
rsync -avzhP -e "ssh -p 2222" [email protected]:/storage/6632-6330/DCIM/Camera/* .

Password authentication Password: exec request failed on channel 0 rsync: connection unexpectedly closed (0 bytes received so far) [receiver] rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-52.200.1/rsync/io.c(453) [receiver=2.6.9]

As you can see, I ran into an error on step 3. From some basic snooping on forums, it seems like rsync needs to be installed on the Android remote device.

(That's also backed up by the fact that which rsync returns nothing when executed from the Android shell)

However:

  • How do I go about installing rsync on the phone? Is this even the right solution here?
  • I never needed to do this on my previous phone (Galaxy S7), the above rsync process "just worked". Did something change with the standard installation of Android with regards to rsync ?
user2490003
  • 111
  • 2
  • I've never tried that, but maybe Syncopoli could help. It describes itself as "An rsync client that works", so it hopefully, erm, works. – Izzy Jul 22 '20 at 07:18
  • Obviously you need rsync binary on Android side for syncing to work. rsync has never been a part of standard Android installation. // You can use Termux for both sshd and rsync. Simple. Or put rsync binary somewhere on your $PATH. // Another idea is to use rclone on both sides with sftp built-in server. // Why you log in as user u0_a312 (the app's UID) and not my_user, the concept of users and login in Android: https://android.stackexchange.com/questions/209918 – Irfan Latif Jul 22 '20 at 08:16
  • Answer here well help on how to install – beeshyams Jul 24 '20 at 07:02
  • Answer here may be of some interest https://android.stackexchange.com/a/179899/131553 – beeshyams Jul 24 '20 at 07:04
  • 1
    Hi @user2490003 everything you are doing is right and the reason its not working is SSH/SFTP server does not support rsync. Just use the app called SimpleSSHD from playstore and it will work with your existing commands..Only pain is there's a little extra work to do and that is you need to copy the id_rsa.pub file to the apps authorised_keys folder for passwordless authentication. – Jagdish Adusumalli Oct 30 '21 at 19:25

1 Answers1

2

First on Android each app has an own user-id/account, hence u0_a312is the user of the app that runs the ssh server. Regular Linux user accounts like myuser don't exist on Android.

Based on the path /storage/6632-6330/ I would assume that you are trying to access the external sd-card.

On a non-rooted device write access to ext-sd is not possible on Android using standard Linux/Unix file programs (this is only possible via Android Java API). Only if the ssh/ftp server + rsync was specially adopted to use this API it can work.

On Android 10/11 the situation is even getting worse because of the new "Scoped storage" system. Not sure if it is still possible to get full access to all files on the external ad-card.

Robert
  • 20,025
  • 6
  • 47
  • 66