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便可。