6
August
2020
10:36

Transfer large files from smartphone to PC running Linux

6 August 2020 10:36

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

Unfortunately, the solution for transferring files using the ShareIt program is not suitable - there is no client for Linux, there is only emulation.
I didn’t consider the option with “clouds” (disk.yandex.ru, Google Drive, Mail.ru Cloud) due to overhead costs - transferring to a third-party server via the Internet, and then downloading from it. Bluetooth doesn't work - too slow. I chose the proven option with an FTP server on a personal computer.

Procedure:

  1. picked it up on the computer FTP server proftpd:

sudo apt-get install proftpd

Changed the 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 # ftp root directory name

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

<Directory> /home/vladimir/ftp/upload/> # subdirectory "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 your own

<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 # Allowed login for FTP
DenyALL # Entry is prohibited for others
</Limit>

UserAlias ftp vladimir2 # FTP login as username vladimir2

Include /etc/proftpd/conf.d/

  • also changed the shells file, added nologin
    When executing sudo nano /etc/shells added last line

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

  • changed ftp user password:

    sudo passwd ftp

  • checked the service configuration:

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

  • started the proftpd service:

    sudo /etc/init.d/proftpd start

  • checked from the client that the connection to the server is working:

    ftp my_IP-address

entered username ftp" and the ftp user password, entered the directory - everything is in order.

    1. Installed on Android phone File manager from Google PlayMarket:FileManager.
      Another powerful FTP client -AndFTP
  1. both devices - the PC and the smartphone are connected to the same local network (via Wi-Fi or wire - it doesn’t matter).
  2. Connected from a smartphone through the “File Manager” - the “Remote Services” icon to the FTP server using its IP address (entered login and password) and transferred the files to the computer.

Uploading files from a PC not a phone (add 10/01/2021):

If you enable restrictions in the configuration file, you will not be able to transfer files from your PC to your smartphone.
The restriction for 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 I removed them from the file proftpd.conf, because It is often necessary to download from a PC to a phone. Both uploading and downloading to FTP now works.

Solving access problems - addition dated 10/04/2021

After connecting via FTP, it is not possible to create a file or directory on the FTP server

I encountered this problem on the Sparky Linux operating system (Debian variant).

Symptoms:
On a Debian PC, after connecting to an FTP server from a smartphone, neither a file nor a directory can be created to upload files from the smartphone to the PC. In this case, the FTP client writes an error on the screen “Access denied” or “File not found”.

Main errors and solutions to problems:
1.Problems with paths

  • Check that the paths in the proftpd.conf file to the "public" or "upload" directory match the real paths and folder names on the user's computer (for example,/home/vladimir/ftp/upload etc.).

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

  • Run the command in the console:

    sudo chmod -R 0775 /home/user/ftp

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

3.Assigning the "Owner" of the directory
The problem occurs on Debian OS.

  • Run the command in the terminal:

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

where ftp is the account under which proftpd runs, users is the “all users” group.

or, for a stronger restriction of rights:

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

Note: default owner user:user
where user- Your username and group.

An error occurs when running proftpd on Debian with a configuration file from Ubuntu

You need to delete the line in the configuration file (sudo nano /etc/proftpd.conf):
IdentLookups off

Problems with the proftpd service in Linux Mint 21 "Vanessa" and their solution (08/23/2022)

When switching to Linux Mint 21 "Vanessa", the first problem arose - the installation program pointed to the "proftpd" package that was incompatible with Mint 21.
I was forced to remove it before updating using "mint-update":

sudo apt-get remove proftpd

After successfully switching to LM 22, I tried to install the program, but a second problem arose - proftpd installation errors:

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

Solution:

sudo nano /etc/proftpd/modules.conf

Comment out many modules. I only left a few pieces. Here is the file modules.conf after disabling the lines in it:

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 commented out the line called "IdentLookups":

sudo nano /etc/proftpd/proftpd.conf

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

The final touch - removed the systemd mask from the proftpd service

sudo systemctl unmask proftpd.service

Now the service installation went smoothly:

sudo apt-get install proftpd

Enabling and starting the proftpd service also without “incidents”:

systemctl enable proftpd.service
systemctl start proftpd.service
systemctl status proftpd.service

I tracked the errors that occurred using the journalctl -xeu command:

journalctl -xeu proftpd.service

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

Check - connecting from a smartphone using the program "File Manager+"- Remote - FTP to the IP address of a PC with a known username and password is completed. The directory has been read and the files have been transferred.


Links:



Related publications