Jun 14, 2019 // posted on
This is a guide to setting up
rsync on Android and Linux. I use this to sync
music and it has served me well.
rsyncon both devices. Praise be to package managers.
passwdto have a password.
termux-setup-storageto grant Termux access to your phone's storage.
The device being
ssh'd into needs to have the daemon running. I prefer to run
it on my phone.
sshdto start the daemon.
killall sshdto kill it. (RIP)
sshd defaults to port 8022. The network addresses can be
Extensive documentation on
ssh for Termux is available on the wiki page.
ssh keys on either device, run the following command:
ssh-keygen [-t rsa] [-b 4096]
Default location for
ssh stuff is
id_rsais the private key. Never share this with anyone.
id_rsa.pubis your public key.
authorized_keysis a list of public keys are the allowed to
sshinto the device.
known_hostsis a list of known hosts that have been previously
Here is a tidy high-level explanation to public-private asymmetrical key pairs.
This makes life ridiculously convenient.
To copy a device's public key to a target:
ssh-copy-id [-p <port>] <target_address>
I wasn't able to copy my public key from my computer to my phone without having
passwd on my phone.
This can also be done manually. The goal is to append destination's
~/.ssh/id_rsa.pub to target's
~/.ssh/authorized_keys as a single line.
sshing into a device like so:
$ ssh [-p 8022] <target_address>
Ayy we did it! (Hopefully.)
rsync - a fast, versatile, remote (and local) file-copying tool
It is a great tool. I love it.
The command that I run on my computer looks like this:
$ rsync --recursive --verbose --progress --ignore-existing\ [--delete]\ -e 'ssh -p 8022'\ ~/Music/synced_music/\ <phone_address>:/sdcard/Music/synced_music
--deletedeletes files that I have deleted on my computer.
/. This is intended. Different behaviours are exhibited with and without it:
rsyncmakes sure destination and target are synced.
rsynccopies destination into target.
This whole thing is a hack with a downside.
sshd is notoriously slow over
local WiFi connections. See
This isn't too big a deal when the transfer size is small but, otherwise, it can
Github user Neo-oli has suggested workarounds HERE . I'll copy and paste them here for convenience.
adb forward tcp:8022 tcp:8022 to forward the phone's port to localhost's
ssh someserver -t -- "while true;do sleep 0.1; date;done";
rsync do not float your rafter (cries), other options are
adb, packaged with
android-tools, on most distros, has sync, pull and push options and can be used over the network. (I think.)
android-file-transferis available on most distros but is rudimentary.
mtpfsallows mounting MTP devices as file systems.
EDIT: Much better ha!