This guide documents the exact setup for building: syncing music files locally between an Android phone and a Windows PC using SSH + rsync, without Wi‑Fi LAN, without WSL, and without cloud services.
The phone provides internet via hotspot, and the connection is initiated from the phone to the PC.
Android hotspot blocks incoming connections to the phone, but allows outgoing connections.
Warning
Using SSH Connection attempts from the PC are blocked when using the phone’s hotspot due to Android’s hotspot firewall.
So this is the right approach:
Phone ──SSH + rsync──▶ PC
Therefore:
-
Windows runs OpenSSH Server
-
Android (Termux) runs SSH client + rsync
-
rsync is executed from the phone
Open PowerShell as Administrator.
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType AutomaticAdd a firewall rule to accept connections
New-NetFirewallRule -Name "OpenSSH-Server-Inbound" -DisplayName "OpenSSH Server (Inbound)" -Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 -Action AllowVerify the service:
Get-Service sshdTest the connection:
ssh localhostNote
Authentication If it asks for a password, use your Windows account password. If that doesn't work, the next section includes a key-based workaround.
To obtain a key to grant access to yourself run:
ssh-keygen -t ed25519 -C "yourUserName@localhost"This will prompt for a passphrase, just press enter twice, so you now have a public and private key in:
C:\Users\yourUser\.ssh
With this two files:
id_ed25519
id_ed25519.pub
may be more but the id_ed25519.pub are the one that we gonna use, now open the file and copy all
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBASE64DATA YourUserName@localhost
All in one line
Windows OpenSSH ships with this rule enabled by default:
Match Group administrators
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
If your user is in Administrators (most personal PCs):
-
C:\Users\<you>\.ssh\authorized_keysis ignored -
Keys MUST be placed in:
C:\ProgramData\ssh\administrators_authorized_keys
-
If you don't have the file, create it, notice that the file doesn't have an extension
-
Paste your public key in the file, all in one line
-
Restart the SSH service using:
Restart-Service sshd- Try to connect to
ssh localhostagain. (It should connect without asking for password)
Without correct ACLs, Windows OpenSSH will silently reject keys.
icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r
icacls C:\ProgramData\ssh\administrators_authorized_keys /grant "Administrators:(F)"
icacls C:\ProgramData\ssh\administrators_authorized_keys /grant "SYSTEM:(F)"Restart SSH:
Restart-Service sshdInstall Termux from Play Store, then:
pkg update
pkg install openssh rsyncExecute:
ssh-keygen -t ed25519Your public key:
cat ~/.ssh/id_ed25519.puband repeat the process with the Windows one.
-
Enable hotspot on the phone
-
Connect the PC to it
-
Determine PC IP address (on Windows):
ipconfigExample:
IPv4 Address: 192.168.57.195From Termux:
ssh <windows_user>@192.168.57.195Expected:
-
No password
-
Successful login
Example paths:
- Phone music:
/storage/emulated/0/Music/
- PC destination:
C:/Users/<windows_user>/Music/
Run from Termux:
rsync -av --delete \
/storage/emulated/0/Music/ \
<windows_user>@192.168.57.195:/c/Users/<windows_user>/Music/Warning
Command not recognized on Windows Windows doesn't have rsync by default, you must to install it using something like MSYS2 and running
pacman -Syu
pacman -Su
pacman -S rsyncAnd add the route to the path:
setx /M PATH "%PATH%;C:\msys64\usr\bin"-
-a: archive (permissions, timestamps) -
-v: verbose -
--delete: remove files deleted on the phone -
--exclude: excludes folders or files from checking -
--inplace: writes the updated data directly to the existing destination file -
--progress: This provides a breakdown for each file, including:- File size and current transfer percentage (e.g.,
12.3M 100%) - Transfer speed (e.g.,
86.15MB/s) - Estimated time remaining for that specific file (e.g.,
0:00:00) - A "to-check" statistic, showing how many files are left to process out of the total file list
- File size and current transfer percentage (e.g.,
This repo includes two helper scripts:
-
sync_music.sh(run on Android / Termux)- Builds a SHA-256 index for the phone library.
- Uses a local cache (
size + mtime) to avoid re-hashing unchanged files. - Syncs files to the PC with
rsync, then uploadsmusica.sha256into.index/on the destination.
-
Verify-Music.psm1(run on Windows / PowerShell)- Verifies the files on the PC against
.index\musica.sha256. - Writes a timestamped snapshot of current hashes into
.snapshots\.
- Verifies the files on the PC against
Tip
Filesystem paths (MSYS2/Cygwin vs Windows)
The example destinations use MSYS2-style paths like /d/Music.
From Termux, in the folder where sync_music.sh lives:
chmod +x ./sync_music.sh
# Required (example)
DST="<windows_user>@<pc_ip>:/d/Music" \
SRC="/storage/emulated/0/Music" \
./sync_music.shUseful options:
# Show progress every 50 files
DST="<windows_user>@<pc_ip>:/d/Music" PROGRESS_EVERY=50 ./sync_music.sh
# Print cache-hit lines (very verbose)
DST="<windows_user>@<pc_ip>:/d/Music" DEBUG=1 ./sync_music.shNotes:
-
DSTmust be in rsync remote format:user@host:/absolute/or/msys-path. -
The script uploads
musica.sha256toDST/.index/(make sure that folder exists on the PC side).
In PowerShell, from the repo folder:
Import-Module .\Verify-Music.psm1 -Force
# Default base path is your Windows "Music" folder
Invoke-VerifyMusic
# Or specify the destination folder explicitly
Invoke-VerifyMusic -PathBase 'D:\Music'Telemetry options:
# Print a progress line every 50 entries
Invoke-VerifyMusic -PathBase 'D:\Music' -ProgressEvery 50
# Print OK lines too (very verbose)
Invoke-VerifyMusic -PathBase 'D:\Music' -Details