All commands should be run with ‘root’ user. Run the following command in terminal to install vsftpd package:linux
yum install vsftpd ftp -y
Edit vsftpd configuration file /etc/vsftpd/vsftpd.conf,centos
vi /etc/vsftpd/vsftpd.conf
Find the following lines and make the changes as shown below:tcp
[...] ## Disable anonymous login ## anonymous_enable=NO ## Uncomment ## ascii_upload_enable=YES ascii_download_enable=YES ## Uncomment - Enter your Welcome message - This is optional ## ftpd_banner=Welcome to UNIXMEN FTP service. ## Add at the end of this file ## use_localtime=YES
Enable and start the vsftpd service:this
systemctl enable vsftpd systemctl start vsftpd
Allow the ftp service and port 21 via firewall.code
firewall-cmd --permanent --add-port=21/tcp firewall-cmd --permanent --add-service=ftp
Restart firewall:orm
firewall-cmd --reload
Then, update the SELinux boolean values for FTP service:server
setsebool -P ftp_home_dir on
By default, root user is not allowed to login to ftp server for security purpose. So, let us create a normal testing user called “sk” with password “centos”.ci
useradd sk passwd sk
Now, try to connect to FTP server itself with user “sk”:terminal
ftp 192.168.1.101
Enter the ftp user name and password.cmd
Sample Output:
Connected to 192.168.1.101 (192.168.1.101). 220 Welcome to UNIXMEN FTP service. Name (192.168.1.101:root): sk 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>
最后,若是出现500 OOPS: chroot的错误,说明系统中没有ftp_home_dir目录,那么须要用如下命令代替:
setsebool -P ftpd_full_access 1若是出现ftp能链接,可是ls出现connect refuse的错误,须要将selinux关闭。修改方法为打开/etc/selinux/config文件,将SELINUX改成disabled便可。