Reprint: http://zyjustin9.iteye.com/blog/2178943
One. Installation
1. Install the VSFTPD with the Apt-get tool:
Java code
- $ sudo apt-get install vsftpd
2. Check if the FTP port is already open
Java code
- $ netstat-tnl
or enter "ftp://server IP" directly in the browser.
Commands to turn on, stop, and restart the VSFTPD service:
XML code
- Service VSFTPD Start | Stop | Restart
Two. Configuration
1. Modify the configuration file
Java code
- $ sudo vi/etc/vsftpd.conf
Main configuration:
XML code
- listen=YES # Server monitoring
- local_enable=YES # allows local users to access
- write_enable=YES # is allowed to upload files, do not open will be reported 550 permission denied
- anonymous_enable=No # Anonymous access allowed, default does not open,
- #anon_upload_enable=Yes # anonymous upload allowed, default is no
- #anon_mkdir_write_enable=YES # Anonymous Create folder allows
Permission settings for the user to access the directory:
In the default configuration, a local user can switch to a different directory using the CD command after logging in to FTP, which poses a security risk to the system. You can control the user to switch directories by using the following three configuration files.
XML code
- chroot_local_user=YES To specify whether users in the user list file are allowed to switch to the parent directory. The default value is No.
- chroot_list_enable=YES # Sets whether the user list file specified by the Chroot_list_file configuration item is enabled. The default value is No.
- Chroot_list_file=/etc/vsftpd.chroot_list
- #禁用的列表名单, in the form of a single user, that specifies a user list file that controls which users can switch to the parent directory of the user's home directory.
The following effects can be achieved by pairing:
XML code
- (1). When chroot_list_enable=Yes,chroot_local_user=Yes, users listed in the/etc/vsftpd.chroot_list file can switch to a different directory , users who are not listed in the file cannot switch to a different directory.
- (2). When chroot_list_enable=YES,chroot_local_user=No, users listed in the/etc/vsftpd.chroot_list file cannot switch to a different directory , users who are not listed in the file can switch to a different directory.
- (3). When chroot_list_enable=No,chroot_local_user=Yes, all users cannot switch to a different directory.
- (4). When chroot_list_enable=No,chroot_local_user=No, all users can switch to a different directory.
Additional Configuration explanations:
XML code
- local_umask=022 # Local file permissions on FTP, default is 077
- dirmessage_enable=YES # Enter folder Allow
- xferlog_enable=YES # FTP log records allow
- connect_from_port_20=YES # Enable Port 20th as the port for data transfer
- xferlog_enable=Yes # activates uploads and down logs
- xferlog_std_format=Yes # uses the standard log format
- ftpd_banner=XXXXX # Welcome Info
RELATED links:
VSFTPD configuration file Detailed
2. Restart the VSFTPD service
Java code
- $sudo/etc/init.d/vsftpd Restart
- Or
- $ sudo service vsftpd restart
Note: You must restart the service to take effect after modifying the configuration file
Three. FTP Add delete User
1. Add Users
#创建目录
Java code
- Mkdir-p/home/test
#创建用户
Java code
- sudo useradd-g ftp-d/home/test-m test
(Note: G: The user's Group D: the location to create the user's own directory given m: Do not establish the default home directory, that is, there is no own directory under//)
#设置用户口令
Java code
- sudo passwd test123
Edit the/etc/vsftpd.chroot_list file, add the FTP account name, save the exit
Restart VSFTPD:
Java code
- $ sudo service vsftpd restart
Note: After you modify the user rights file Vsftpf.chroot_list file, you must restart the service to take effect
2. Delete a user
Java code
- $ sudo userdel test
Four. Uninstall
sudo apt-get remove--purge vsftpd
(--purge option means complete removal of software and related files)
Install config and uninstall FTP (GO) in Ubuntu