You can run a SSH server on Termux, so yes, no reason you couldn’t.
Though given how aggressive background app management has gotten on Android, you’ll likely have to use the ‘Wakelock’ function which will keep a permanent notification on your status bar, and even then Termux might still not survive depending just how aggressive your OEM/ROM is.
Does that let you do it both ways? I want to run rsync from the desktop
Its basically a Linux terminal for your phone that can run rsync, so it should work both ways.
You can run a SSH server on Termux, so yes, no reason you couldn’t.
Though given how aggressive background app management has gotten on Android, you’ll likely have to use the ‘Wakelock’ function which will keep a permanent notification on your status bar, and even then Termux might still not survive depending just how aggressive your OEM/ROM is.