yum install vsftpd
To configure the server, we will edit the file etc/vsftpd/vsftpd.conf. Open this file:
sudo nano -w etc/vsftpd/vsftpd.conf #открываем в редакторе файл конфигурации
First, you need to disable anonymous FTP access. This can be done by changing the value of the anonymous_enable parameter to NO.
Next, uncomment the options “local_enable”, “write_enable”, and “chroot_local_user”.
local_enable – this option allows users registered in the system to log in to the server.
write_enable – allows users to execute any FTP commands.
chroot_local_user (default value YES) – prevents users from escaping the chroot jail, meaning they will not be able to access other files on the server. Access will be limited only to within their home directories.
Create a new user named user for FTP. This can be done with the following command:
sudo useradd -d /var/www/path/to/your/dir -s /sbin/nologin user
Next, set a password for the user user:
sudo passwd user #меняем пароль пользователя user
Then, create the home directory for the user user:
sudo mkdir -p /var/www/path/to/your/dir
Check if the directory was created:
sudo ls -la /var/www/path/to/your/dir/span>
To allow the user user to read and write in their home directory, change the permissions:
pre lang=”ru-RU”>sudo chown -R user /var/www/path/to/your/dir # change the directory owner
sudo chmod 775 /var/www/path/to/your/dir #разрешаем запись в каталог
Create a group ‘webusers’ for FTP users, and add ‘user’ to it:
sudo groupadd webusers #создаем группу webusers
sudo usermod -G webusers user #добовляем пользователя user в группу
Restart the FTP server:
sudo service vsftpd restart
CONFIGURING ANONYMOUS ACCESS TO THE FTP SERVER
Edit the file etc/vsftpd/vsftpd.conf
sudo nano -w etc/vsftpd/vsftpd.conf
The option anonymous_enable allows enabling anonymous FTP access:
anonymous_enable=YES #Включаем если была выключена
After installation, anonymous file uploads are enabled and occur in the default directory /srv/ftp. During installation, a user named ftp is created with the home directory /srv/ftp. If you want to change this, simply create a new directory and update the home directory for the ftp user:
sudo mkdir /var/www/path/to/your/dir #создаем папку
sudo usermod -d /var/www/path/to/your/dir ftp # назначаем пользователю user
With this configuration, anonymous access will be granted to the directory /var/www/path/to/your/dir.
After making changes, restart vsftpd:
sudo service vsftpd restart
