• Re: ftp or sftp server [Was: How do nonroot Android & nonjailbroken iOS

    From Carlos E.R.@21:1/5 to Carlos E.R. on Fri Apr 25 15:43:43 2025
    XPost: misc.phone.mobile.iphone, comp.mobile.android

    On 2025-04-25 13:21, Carlos E.R. wrote:
    On 2025-04-25 10:37, Herbert Kleebauer wrote:
    On 25.04.2025 02:09, Carlos E.R. wrote:
    On 2025-04-25 00:01, Herbert Kleebauer wrote:

    https://f-droid.org/packages/org.primftpd/

    ...

    I try again on my main phone. First I install it (I had uninstalled it).
    Run it, go to configure, it says "create keys?", I say yes (I did not
    see this prompt yesterday). I configure user name and password, go to
    main screen, hit run, it does not die and both ftp and sftp are active.
    AND, I successfully connect using both sftp and ftp.

    If we have "sftp", maybe we can use "sshfs", which would allow a mount, and thus do rsync. It connects, but permissions are too restrictive.

    cer@Telcontar:~/tmp> sshfs -p 1234 cer@192.168.2.18:/ /home/cer/fusermount/ (cer@192.168.2.18) Password:
    cer@Telcontar:~/tmp> ls ~/fusermount/
    storage
    cer@Telcontar:~/tmp> ls ~/fusermount/storage/
    ls: reading directory '/home/cer/fusermount/storage/': Permission denied cer@Telcontar:~/tmp> ls ~/fusermount/
    storage
    cer@Telcontar:~/tmp> l ~/fusermount/
    total 0
    d--x--x--x 1 bin bin 0 Nov 3 1971 storage/
    cer@Telcontar:~/tmp> l ~/fusermount/
    total 0
    d--x--x--x 1 bin bin 0 Nov 3 1971 storage/
    cer@Telcontar:~/tmp>

    We need 'rx' permissions to traverse the directory tree.

    The problem is the same with sftp:


    cer@Telcontar:~/tmp> sftp -P 1234 cer@192.168.2.18
    Password authentication
    (cer@192.168.2.18) Password:
    Connected to 192.168.2.18.
    sftp> dir
    Alarms Android Audiobooks DCIM Documentos Documents Download
    Fotos.smsng Fotos.xplay FotosClasificadas Movies Music Nikon_WU Notifications
    OtherMediaBackup Pictures Pixlr Pl@ntNet PlantNet Podcasts Recorders
    Recordings Ringtones WhatsApp
    sftp> dir /
    /storage
    sftp> dir /storage/
    remote readdir("/storage/"): Permission denied
    sftp>

    sftp> dir /storage/
    remote readdir("/storage/"): Permission denied
    sftp> dir ..
    remote readdir("/storage/emulated/0/../"): Permission denied
    sftp>
    sftp> dir /storage/emulated/0/
    /storage/emulated/0/Alarms /storage/emulated/0/Android /storage/emulated/0/Audiobooks
    /storage/emulated/0/DCIM /storage/emulated/0/Documentos /storage/emulated/0/Documents
    /storage/emulated/0/Download /storage/emulated/0/Fotos.smsng /storage/emulated/0/Fotos.xplay
    /storage/emulated/0/FotosClasificadas /storage/emulated/0/Movies /storage/emulated/0/Music
    /storage/emulated/0/Nikon_WU /storage/emulated/0/Notifications /storage/emulated/0/OtherMediaBackup
    /storage/emulated/0/Pictures /storage/emulated/0/Pixlr /storage/emulated/0/Pl@ntNet
    /storage/emulated/0/PlantNet /storage/emulated/0/Podcasts /storage/emulated/0/Recorders
    /storage/emulated/0/Recordings /storage/emulated/0/Ringtones /storage/emulated/0/WhatsApp
    sftp>


    So, progress :-)

    cer@Telcontar:~/tmp> sshfs -p 1234 cer@192.168.2.18:/storage/emulated/0/ /home/cer/fusermount/
    (cer@192.168.2.18) Password:
    cer@Telcontar:~/tmp> dir ~/fusermount/
    total 0
    drwxrwxrwx 1 bin bin 0 Mar 4 2022 Alarms
    dr-xr-xr-x 1 bin bin 0 Mar 4 2022 Android
    drwxrwxrwx 1 bin bin 0 Mar 4 2022 Audiobooks
    drwxrwxrwx 1 bin bin 0 Mar 16 2023 DCIM
    dr-xr-xr-x 1 bin bin 0 Sep 5 2024 Documentos
    drwxrwxrwx 1 bin bin 0 Apr 25 04:40 Documents
    drwxrwxrwx 1 bin bin 0 Apr 24 22:59 Download
    dr-xr-xr-x 1 bin bin 0 May 2 2022 Fotos.smsng
    dr-xr-xr-x 1 bin bin 0 May 2 2022 Fotos.xplay
    dr-xr-xr-x 1 bin bin 0 Jun 17 2023 FotosClasificadas
    drwxrwxrwx 1 bin bin 0 Mar 4 2022 Movies
    drwxrwxrwx 1 bin bin 0 Mar 5 2023 Music
    dr-xr-xr-x 1 bin bin 0 May 15 2022 Nikon_WU
    drwxrwxrwx 1 bin bin 0 May 2 2022 Notifications
    dr-xr-xr-x 1 bin bin 0 May 2 2022 OtherMediaBackup
    drwxrwxrwx 1 bin bin 0 Mar 2 21:18 Pictures
    dr-xr-xr-x 1 bin bin 0 Oct 16 2022 Pixlr
    dr-xr-xr-x 1 bin bin 0 May 2 2022 Pl@ntNet
    dr-xr-xr-x 1 bin bin 0 May 2 2022 PlantNet
    drwxrwxrwx 1 bin bin 0 Mar 4 2022 Podcasts
    dr-xr-xr-x 1 bin bin 0 May 2 2022 Recorders
    drwxrwxrwx 1 bin bin 0 Mar 4 2022 Recordings
    drwxrwxrwx 1 bin bin 0 May 2 2022 Ringtones
    dr-xr-xr-x 1 bin bin 0 Oct 26 2023 WhatsApp
    cer@Telcontar:~/tmp>


    Wow! so, now I can try rsync.

    (this is one advantage of ftp/sftp over the usb cable: we are not limited by MTP quirks)


    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52> cat bcksshfs
    #!/bin/bash

    OPTIONS="--archive --acls --xattrs --hard-links --sparse --stats --human-readable "
    #--del
    #--modify-window=1

    DESTINO=2025-04-25
    PREVIO=2022-05-02

    rsync $OPTIONS --link-dest=../$PREVIO \
    ~/fusermount/ $DESTINO

    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52> ./bcksshfs
    rsync: [sender] readdir("/home/cer/fusermount/Android/data"): Permission denied (13)
    rsync: [sender] readdir("/home/cer/fusermount/Android/obb"): Permission denied (13)

    Number of files: 434 (dir: 434)
    Number of created files: 353 (dir: 353)
    Number of deleted files: 0
    Number of regular files transferred: 0
    Total file size: 0 bytes
    Total transferred file size: 0 bytes
    Literal data: 0 bytes
    Matched data: 0 bytes
    File list size: 0
    File list generation time: 0,393 seconds
    File list transfer time: 0,000 seconds
    Total bytes sent: 12,08K
    Total bytes received: 1,78K

    sent 12,08K bytes received 1,78K bytes 413,70 bytes/sec
    total size is 0 speedup is 0,00
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1336) [sender=3.2.7]
    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52>


    There is another problem: I only see directories, not files. Might be a permission problem? Everything seems owned by "bin". Maybe repeat as root.




    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52> su
    Password:
    Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 # Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 # cat ./bcksshfs #!/bin/bash

    OPTIONS="--archive --acls --xattrs --hard-links --sparse --stats --human-readable "
    #--del
    #--modify-window=1

    DESTINO=2025-04-25
    PREVIO=2022-05-02

    rsync $OPTIONS --link-dest=../$PREVIO \
    /home/cer/fusermount/ $DESTINO

    Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 # Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 # ./bcksshfs
    rsync: [sender] readdir("/home/cer/fusermount/Android/data"): Permission denied (13)
    rsync: [sender] readdir("/home/cer/fusermount/Android/obb"): Permission denied (13)

    Number of files: 434 (dir: 434)
    Number of created files: 353 (dir: 353)
    Number of deleted files: 0
    Number of regular files transferred: 0
    Total file size: 0 bytes
    Total transferred file size: 0 bytes
    Literal data: 0 bytes
    Matched data: 0 bytes
    File list size: 0
    File list generation time: 0,339 seconds
    File list transfer time: 0,000 seconds
    Total bytes sent: 12,08K
    Total bytes received: 1,78K

    sent 12,08K bytes received 1,78K bytes 311,44 bytes/sec
    total size is 0 speedup is 0,00
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1336) [sender=3.2.7]
    Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 #

    Nope.

    Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 # l /home/cer/fusermount/DCIM/Camera/
    total 0
    drwxrwxrwx 1 bin bin 0 Jul 11 2024 Thumbnail/
    drwxrwxrwx 1 bin bin 0 Mar 27 13:44 bf56b4888c57b866c97eyy/ Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 #

    Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 # fusermount -u /home/cer/fusermount
    Telcontar:/home/cer/Varia/Gadgetos/MovilMotorolaG52 #

    It just does not see the files. No go.

    But it is not just sshfs, it is plain sftp that fails:

    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52/tmp> sftp -P 1234 cer@192.168.2.18:/storage/emulated/0/
    Password authentication
    (cer@192.168.2.18) Password:
    Connected to 192.168.2.18.
    Changing to: /storage/emulated/0/
    sftp> dir
    Alarms Android Audiobooks DCIM Documentos Documents Download
    Fotos.smsng Fotos.xplay FotosClasificadas Movies Music Nikon_WU Notifications
    OtherMediaBackup Pictures Pixlr Pl@ntNet PlantNet Podcasts Recorders
    Recordings Ringtones WhatsApp
    sftp> dir DCIM
    DCIM/Camera DCIM/ImageApp DCIM/MiWatch DCIM/PlantNet
    sftp> dir DCIM/Camera/
    DCIM/Camera/Thumbnail DCIM/Camera/bf56b4888c57b866c97eyy
    sftp> cd DCIM/Camera/
    sftp> dir
    Thumbnail bf56b4888c57b866c97eyy
    sftp>

    sftp> bye
    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52/tmp>


    There just there are no files seen on sftp. That's pretty bad. And plain FTP?


    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52/tmp> ftp -P 12345 cer@192.168.2.18
    Connected to 192.168.2.18.
    220 Service ready for new user.
    331 User name okay, need password for cer.
    Password:
    230 User logged in, proceed.
    Remote system type is UNIX.
    Using binary mode to transfer files.
    dir
    229 Entering Passive Mode (|||5678|)
    150 File status okay; about to open data connection.
    dr-x------ 0 cer cer 0 Mar 4 2022 Android
    drwx------ 0 cer cer 0 Mar 5 2023 Music
    drwx------ 0 cer cer 0 Mar 4 2022 Podcasts
    ...
    226 Closing data connection.
    dir DCIM
    229 Entering Passive Mode (|||5678|)
    150 File status okay; about to open data connection.
    drwx------ 0 cer cer 0 Apr 24 21:16 Camera
    drwx------ 0 cer cer 0 Sep 27 2023 PlantNet
    drwx------ 0 cer cer 0 Feb 23 2023 ImageApp
    drwx------ 0 cer cer 0 Mar 7 2024 MiWatch
    226 Closing data connection.
    dir DCIM/Camera
    229 Entering Passive Mode (|||5678|)
    150 File status okay; about to open data connection.
    drwx------ 0 cer cer 0 Jul 11 2024 Thumbnail
    drwx------ 0 cer cer 0 Mar 27 13:44 bf56b4888c57b866c97eyy
    226 Closing data connection.
    bye
    cer@Telcontar:~/Varia/Gadgetos/MovilMotorolaG52/tmp>


    Well, total failure.




    --
    Cheers, Carlos.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)