A simple example of setting up an FTP server

  • 2020-06-15 10:37:10
  • OfStack

The FTP server setup is very simple


apt-get install vsftpd

Turning on, stopping, and restarting the vsftpd service is also simple


service vsftpd start | stop | restart

account

After installation, an ftp group and ftp users are produced

Change user password


passwd ftp

configuration

Key configuration, modify vsftpd configuration file vi /etc/ vsftpd.conf

# Disable anonymous access


anonymous_enable=NO
# Accept local users 
local_enable=YES
# You can upload 
write_enable=YES
# To enable the chroot_list_file Users can only access the root directory 
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
# Set the fixed directory and add it at the end. If you don't add this 1 Line, each user corresponds to its own directory 
local_root=/srv/ftp

Access permissions

chroot_list_file exception file path, default is /etc/ vsftpd.chroot_list

chroot_list_enable Whether chroot_list_file configuration file is enabled

The file for the YES chroot_list_file configuration takes effect The file for the NO chroot_list_file configuration is invalid

chroot_local_user prohibits access to other directories

YES chroot_list_file configuration file, users cannot switch to a directory other than their home directory NO chroot_list_file configuration file, the user can switch to

Error handling

530 login incorrect

Two ways to do it

1). Modify the file vi/etc/pam d/vsftpd, commented out


#auth  required pam_shells.so

2). Add /sbin/nologin to the last line of /etc/shells

500 OOPS: vsftpd: refusing to run with writable root inside chroot()

Enabling chroot_local_user must set the root directory accessed to be non-writable


chmod a-w /home/user

Thank you for reading, I hope to help you, thank you for your support to this site!


Related articles: