At the end, it pulls its own plug. After unmounting the phone, it sends "pkill sshd" over ssh, to terminate the phone's sshd server.
I use sshfs so that copying from phone to laptop is from mounted directory to local directory. Connection is like so:
# Mount the phone's DCIM ancestor directory locally over ssh.
# mg4: is an ssh host in ~/.ssh/config
sshfs mg4:/storage/emulated/0/ ~/mnt/mg4- Copy them to the laptop.
- On the laptop, make downscaled copies in another directory.
- On the phone, I move them to another location still on the phone. This makes the copy operation above faster, since I use "cp -n" (no-clobber) out of laziness; "Copy all the things! Unless!" This gets slow if there are thousands of pics.
The phone and the laptop sort of back each other up.
I'll be smarter about this as my phone starts to fill up. That's the nice thing about making your own tools, you can change them according to your own specific, weird use cases.