vsftpd — FTP Server
If you like this project, consider supporting me on Buy Me a Coffee ☕️
tags:
- network
- ftp
- vsftpd
- file-transfer
- security
- sysadmin
-
linux
📂 vsftpd Cheatsheet
Description
vsftpd (Very Secure FTP Daemon) is a stable, secure FTP server for Unix/Linux. Supports chroot jails, virtual users, SSL/TLS (FTPS), and passive mode. / vsftpd — стабильный и безопасный FTP-сервер для Unix/Linux. Поддерживает chroot-jails, виртуальных пользователей, SSL/TLS (FTPS) и passive-режим.
Common use cases / Типовые сценарии:
- Legacy FTP file exchange / Устаревший FTP-обмен файлами
- Anonymous download mirrors / Зеркала для anonymous-загрузки
- Automated upload from scripts / Автоматическая загрузка из скриптов
- Chroot-restricted user FTP / FTP с chroot для пользователей
Status: Maintained (Red Hat / upstream). Alternatives: ProFTPD, Pure-FTPd, SFTP (OpenSSH), Samba. / Статус: поддерживается; альтернативы — ProFTPD, Pure-FTPd, SFTP, Samba.
Default ports: 21/tcp (control), passive data ports (configurable range).
Paths: config /etc/vsftpd/vsftpd.conf; chroot /var/ftp/ or per-user.
Cross-reference: Samba, OpenSSL, systemd.
Installation
Install vsftpd / Установка vsftpd
# Debian/Ubuntu
apt install vsftpd
# RHEL/Rocky/Alma/Fedora
dnf install vsftpd
vsftpd -v
systemctl enable --now vsftpd
Configuration
Main files / Основные файлы
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/var/ftp/
vsftpd.conf / vsftpd.conf
/etc/vsftpd/vsftpd.conf
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
allow_writeable_chroot=NO
pasv_enable=YES
pasv_min_port=<PASSIVE_PORT_MIN>
pasv_max_port=<PASSIVE_PORT_MAX>
pam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
ssl_enable=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.key
tls_sslv2=NO
tls_sslv3=NO
systemctl restart vsftpd
Chroot setup / Настройка chroot
mkdir -p /home/<USER>/ftpdir
chown <USER>:<USER> /home/<USER>/ftpdir
# vsftpd.conf: chroot_local_user=YES, allow_writeable_chroot=NO
Core Management
Logs / Логи
journalctl -u vsftpd --no-pager -n 50
tail -f /var/log/vsftpd.log
tail -f /var/log/xferlog
Logrotate / Ротация логов
/etc/logrotate.d/vsftpd
/var/log/vsftpd.log /var/log/xferlog {
weekly
rotate 4
compress
delaycompress
missingok
notifempty
create 0640 root adm
}
Security
Hardening checklist / Чек-лист ужесточения
- Disable anonymous login / Отключите anonymous-доступ
- Enable TLS (FTPS) / Включите TLS (FTPS)
- Use chroot_local_user / Используйте chroot_local_user
- Restrict writable chroot / Ограничьте записываемый chroot
- Use user_list allow-mode / Используйте user_list в режиме allow
- Limit passive ports / Ограничьте passive-порты
- Monitor logs / Мониторьте логи
- Do not run as root if possible / Не запускайте от root
# /etc/vsftpd/ftpusers — block system users
root
bin
daemon
Backup and Restore
Backup / Резервное копирование
tar czf /var/backups/vsftpd-$(date +%F).tar.gz \
/etc/vsftpd /var/ftp
Restore / Восстановление
systemctl stop vsftpd
tar xzf /var/backups/vsftpd-<DATE>.tar.gz -C /
systemctl start vsftpd
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Connection refused | Service down / firewall | Start vsftpd; open 21 |
| 530 Login incorrect | PAM / user_list deny | Check PAM, user_list |
| 550 Permission denied | write_enable / chroot | Enable write; fix perms |
| Passive mode fails | Passive ports blocked | Open pasv port range |
| TLS errors | Cert path / openssl | Check cert files |
systemctl status vsftpd
vsftpd -v
ss -tlnp | grep 21
Comparison Tables
FTP / file transfer servers / FTP / файловые серверы
| Server | Notes |
|---|---|
| vsftpd | Secure, simple |
| ProFTPD | Feature-rich, Apache-like |
| Pure-FTPd | Lightweight |
| OpenSSH SFTP | Encrypted; modern default |
[!WARNING] Plain FTP sends credentials in cleartext. Prefer SFTP or FTPS. / Обычный FTP передаёт пароли открытым текстом — используйте SFTP/FTPS.
Production Runbooks
Runbook: Deploy FTPS server / Развёртывание FTPS
- Install vsftpd / Установить vsftpd
- Generate or install TLS cert / Установить TLS-сертификат
- Write vsftpd.conf with ssl_enable=YES / Настроить конфигурацию
- Configure PAM and user_list / Настроить PAM и user_list
- Create chroot directories; fix permissions / Создать chroot-каталоги
- Open 21 and passive port range / Открыть порты
- Start vsftpd; test FTPS login / Запустить; проверить вход
- Document cert rotation / Задокументировать ротацию сертификатов
Runbook: Restrict user to home FTP only / Ограничение пользователя FTP
- Create system user with shell /bin/false or nologin / Создать пользователя
- Create home/ftpdir owned by user / Создать ftpdir
- Set chroot_local_user=YES; allow_writeable_chroot=NO / Настроить chroot
- Add user to user_list (allow mode) / Добавить в user_list
- Test login; verify cannot leave chroot / Проверить chroot
- Document access / Задокументировать доступ
Documentation Links
- vsftpd man — https://linux.die.net/man/8/vsftpd
- vsftpd.conf — https://linux.die.net/man/5/vsftpd.conf
- vsftpd security — https://security.appspot.com/vsftpd.html