6
August
2020
10:36

Transmission of large files from a smartphone to a PC under Linux

6 August 2020 10:36

Task: upload photos by Wi-Fi from a smartphone to a personal computer running Linux.

Unfortunately, the decision to transfer files using the SH programarEit is not suitable - there is no client for Linux, there is only emulation.
Option with "clouds" (DISk.yandex.ru, Диск Google, Облако Mail.rU) did not consider due to overhead costs - transfer to a third -party server via the Internet, and then downloading from it. Bluetooth is not suitable - too slow. I chose a proven version with FTP.

Procedure:

  1. On the computer raised ftp server Proftpd :

sudo apt-get install proftpd

Changed ProftPD configuration file as follows:

sudo nano /etc/proftpd.conf

Include /etc/proftpd/modules.conf
UseIPv6 off
IdentLookups off
ServerName "my_computer_name"
ServerType standalone
DeferWelcome off

MultilineRFC2228 on
DefaultServer on
ShowSymlinks off

TimeoutNoTransfer 600
TimeoutStalled 600
TimeoutIdle 1200

DisplayLogin welcome.msg
DisplayChdir .message true
ListOptions "-l"

DefaultRoot /home/vladimir/ftp #The name of the root catalog ftp

<Directory /home/vladimir/ftp> # root catalog ftp
Umask 022 022
AllowOverwrite off
<Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD>
DenyAll
</Limit>
</Directory>

<Directory> /home/vladimir/ftp/upload/> # Subfolder "Upload" - for writing, reading, deleting
Umask 022 022
AllowOverwrite on
<Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD>
AllowAll
</Limit>
</Directory>

AllowStoreRestart on

Port 21 # Standard port, but you can change it to yours

<IfModule mod_dynmasq.c>
</IfModule>

MaxInstances 8

User proftpd
Group nogroup

Umask 022 022
AllowOverwrite on

TransferLog /var/log/proftpd/xferlog
SystemLog /var/log/proftpd/proftpd.log

<IfModule mod_quotatab.c>
QuotaEngine off
</IfModule>

<IfModule mod_ratio.c>
Ratios off
</IfModule>

<IfModule mod_delay.c>
DelayEngine on
</IfModule>

<IfModule mod_ctrls.c>
ControlsEngine off
ControlsMaxClients 2
ControlsLog /var/log/proftpd/controls.log
ControlsInterval 5
ControlsSocket /var/run/proftpd/proftpd.sock
</IfModule>

<IfModule mod_ctrls_admin.c>
AdminControlsEngine off
</IfModule>

<Limit LOGIN>
AllowUser vladimir2 # Additional login for ftp
DenyALL # for the rest, the entrance is prohibited
</Limit>

UserAlias ftp vladimir2 # Login FTP as a alias vladimir2

Include /etc/proftpd/conf.d/

  • also changed the Shells file, added NOLOGIN
    When performing sudo nano /etc/shells added the last line

    # /etc/shells: valid login shells
    /bin/sh
    /bin/dash
    /bin/bash
    /bin/rbash
    /usr/sbin/nologin

  • Changed the user's password FTP:

    sudo passwd ftp

  • checked the configuration of the service:

    sudo /etc/init.d/proftpd check-config

  • launched the ProftPD service:

    sudo /etc/init.d/proftpd start

  • I checked from the client that the connection to the server works:

    ftp my_IP-address

introduced the user's name ftp "and the FTP user password, entered the directory - everything is in order.

    1. On the phone under Android I installed File manager from Google Play Market: Filemanager.
      Another powerful FTP client -Andftp
  1. Both devices - PC and smartphone are connected to the same local network (via Wi -Fi or wire - no matter).
  2. Connected from a smartphone via the "File Manager" - "Remote Services" icon to the FTP server by its IP address (entered login and password) and transferred files to the computer.

Unloading of files with a PC is not a phone (addition from 01.10.2021):

If the configuration file is enabled restrictions, it will not be possible to transfer files from a PC to the smartphone.
Restriction of reading and deleting files from the "Upload" folder on FTP is as follows:

<Directory /home/vladimir/ftp/upload/>
<Limit READ DELE>
DenyAll
</Limit>

At first I used these directives, but then removed from the file proftpd.conf, because Often it is necessary and loaded from a PC to the phone. Now the load and unloading on FTP work.

Solution to access problems - addition from 04.10.2021

After connecting via FTP, it is impossible to create a file or catalog on the ftp server

I met this problem in the SP operating systemarky Linux (вариант Debian).

Symptoms:
On a PC under the control of Debian, after connecting to the FTP server, it is impossible to create a file or a directory to upload files from a smartphone to a PC. At the same time, the FTP client writes an error on the screen "access" or "file not found".

Basic errors and problems:

1. Problems with paths

  • Check that the paths in the file proftpd.conf к каталогу "public" или "upload" совпадают с реальными путями, названием папок на компьютере пользователя (например, /home/vladimir/ftp/upload, etc.).

2. Incorrect access rights (no write or create rights)

  • Follow the command in the console:

    sudo chmod -R 0775 /home/user/ftp

Where user - name of the working directory for the user account. This command means that the Owner and the group he belongs to can read, write and execute files in the ftp directories.

3. Assigning an "Owner" to a directory
The problem is found in OS Debian.

  • Follow the command in the terminal:

    sudo chown -R ftp:users /home/user/ftp

where ftp is the account, under which p worksroftpd, users is the group "All users".

Or, for a stronger restriction of rights:

sudo chown -R user:user /home/user/FTP

Note: by default, owner user:user
where user:user - your username and group.

When starting proftpd в Debian with the configuration file from Ubuntu an error occurs

It is necessary to remove in the configuration file (sudo nano /etc/proffd.conf) line:
IdentLookups off

Problems with the service proftpd в Linux Mint 21 "Vanessa" and their decision (23.08.2022)

When switching to Linux Mint 21 "Vanessa" The first problem occurred - the installation program pointed to a package "proftpd" that is incompatible with Mint 21.
I had to remove it before the update with the help "mint-update":

sudo apt-get remove proftpd

After a successful transition to LM 22, I tried to install the program, then the second problem arose - PROFTPD installation errors:

fatal: LoadModule: error loading module 'mod_tls.c'

Solution of the problem:

sudo nano /etc/proftpd/modules.conf

Commented many modules. I left only a few pieces. Here is the file modules.conf после отключения в нём строк:

ModulePath /usr/lib/proftpd
ModuleControlsACLs insmod,rmmod allow user root
ModuleControlsACLs lsmod allow user *
LoadModule mod_ctrls_admin.c
LoadModule mod_load.c
LoadModule mod_dynmasq.c
LoadModule mod_exec.c
LoadModule mod_ratio.c
LoadModule mod_site_misc.c
LoadModule mod_facl.c
LoadModule mod_unique_id.c
LoadModule mod_copy.c
LoadModule mod_deflate.c
LoadModule mod_ifversion.c
LoadModule mod_ifsession.c

Then, in the main configuration file prpftpd I commented line with name "IdentLookups":

sudo nano /etc/proftpd/proftpd.conf

# If set on you can experience a longer connection delay in many cases.
#IdentLookups off

Now I unmasked proftpd service in the SystemD:

sudo systemctl unmask proftpd.service

The installation of the service has passed without problems:

sudo apt-get install proftpd

The inclusion and launch of the ProftpD service is also without "incidents":

systemctl enable proftpd.serVice
systemctl start proftpd.serVice
systemctl status proftpd.serVice

I tracked the errors using the Jou commandrnaLCTL -XEU:

journalctl -xeu proftpd.serVice

Conclusion: data transfer from a smartphone to a PC using ProftpD also works in Linux Mint 22.

Checking - Connection from a smartphone using a program "File manager+" - Remote - FTP to PC IP address with known username and password completed. Directory was read and files transferred.


Links:



Related publications