remount android rootfs writable so you can enable sftp-server

to install ssh server on android https://play.google.com/store/apps/details?id=me.shkschneider.dropbears… first you need remount / as writable then manually create the the /usr/libexec directory and link /system/xbin/sftp-server. clean up by making / read only again.

root@android:/data/local # cat /proc/mounts
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0

.. snip ..

root@android:/data/local # mount -o remount,rw rootfs /
root@android:/data/local # mkdir /usr
root@android:/data/local # mkdir /usr/libexec
root@android:/data/local # ln -s /system/xbin/sftp-server /usr/libexec/
root@android:/data/local # mount -o remount,ro rootfs /

this will get nuked on reboot, so we need to put it in a script /data/local/userinit.sh (putting it in /data/local/userinit.d/ shold work but fails for unknow reason)

#!/system/xbin/bash
mount -o remount,rw rootfs /
mkdir -p /usr/libexec
ln -s /system/xbin/sftp-server /usr/libexec/
mount -o remount,ro rootfs /