Premise
The SSH service is turned on, the firewall is turned off, the host and the virtual function ping Pass
Viewing the status of SSH and firewalls
Service sshd Status
Service Iptables Status
Open SSH Service
Service sshd Start
Shutting down the firewall
Chkconfig iptables off
Testing the connectivity of hosts and virtual machines
Ping 192.168.2.129
Installing and opening TFTP and VSFTPD
[[email protected] ~]# Yum install tftp
[email protected] ~]# Yum install vsftpd
[Email protected] ~]# chkconfig vsftpd on
[[email protected] ~]# chkconfig tftp on
Start the VSFTPD service
Service VSFTPD Start
Viewing the startup status of VSFTPD
Service VSFTPD Status
Open 21 and 20 ports
[[email protected] ~]#/sbin/iptables-i input-p TCP--dport 21-j ACCEPT
[[email protected] ~]#/sbin/iptables-i input-p TCP--dport 20-j ACCEPT
[Email protected] ~]#/etc/rc.d/init.d/iptables Save
Add FTP User
[Email protected] vsftpd]# Useradd Ftpuser
[Email protected] vsftpd]# passwd Ftpuser
Modify the SFTPD. conf configuration file
[[email protected] vsftpd] #vi/etc/vsftpd/vsftpd.conf
Change the anonymous_enable=yes of the first line to No
Note:
VSFTPD configuration, VSFTPD user Connection control configuration is limited in the configuration file. Vsftpd.ftpusers: Located in the/etc directory. It specifies which user accounts cannot access the FTP server, such as root.
Vsftpd.user_list: Located in the/etc directory. The user account in this file cannot access the FTP server by default, only allow access if the USERLIST_ENABLE=NO option is enabled in the VSFTPD. conf configuration file.
Vsftpd.conf: Located in the/ETC/VSFTPD directory. From the configuration of FTP servers that define user Login control, user Rights control, timeout settings, server function options, server performance options, server response messages, and so on. As follows
[email protected] vsftpd]# cat Ftpusers
# Users that is not a allowed to login via FTP
Root
...
[Email protected] vsftpd]#
Restart VSTFPD Service
[Email protected] upload]# service vsftpd restart
Windows cmd Test link
C:\users\administrator>ftp 192.168.1.112
Connect to 192.168.1.112.
(VsFTPd 2.2.2)
User (192.168.1.112: (None)): Ftpuser
331 Specify the password.
Password:
Oops:cannot Change Directory:/home/ftpuser
Login failed.
Ftp> bye
You can see a bug reported: Oops:cannot change Directory:/home/ftpuser. The reason is that the CentOS system has SELinux installed because the default is no FTP-enabled support, so access is blocked. See below:
[Email protected] vsftpd]# Getsebool-a | grep FTP
Allow_ftpd_anon_write--off
Allow_ftpd_full_access--off
Allow_ftpd_use_cifs--off
Allow_ftpd_use_nfs--off
Ftp_home_dir--off
ftpd_connect_db--off
Httpd_enable_ftp_server--off
Tftp_anon_write--off
[Email protected] vsftpd]#
Just change allow_ftpd_full_access---off,ftp_home_dir----to ON. #我这里直接用setenforce 0
[Email protected] vsftpd]# Setsebool Ftp_home_dir 1
[Email protected] vsftpd]# Setsebool allow_ftpd_full_access 1
Turn on SELinux
such as Execution Getsebool-a | grep ftp appears getsebool:selinux is disabled error, need to re-open SELinux
Vi/etc/selinux/config
Changed to: selinux=enabled
Linux must be restarted, no restart is not able to immediately open the SELinux
When you're done restarting, you can use Getsebool-a | grep ftp command.
Check Again
[Email protected] vsftpd]# Getsebool-a | grep FTP
Allow_ftpd_anon_write--off
Allow_ftpd_full_access-On
Allow_ftpd_use_cifs--off
Allow_ftpd_use_nfs--off
Ftp_home_dir-On
ftpd_connect_db--off
Httpd_enable_ftp_server--off
Tftp_anon_write--off
Test the connection again
C:\users\administrator>ftp 192.168.1.112
Connect to 192.168.1.112.
(VsFTPd 2.2.2)
User (192.168.1.112: (None)): Ftpuser
331 Specify the password.
Password:
Successful Login.
Ftp> ls
PORT command successful. Consider using PASV.
Here comes the directory listing.
226 Directory send OK.
Ftp> bye
221 Goodbye.
Ok, the configuration is successful, you can use Flashxftp to upload files.
Flashxftp Uploading Files
First create a directory in the/home directory, and then set the permissions to 777
[Email protected] home]# mkdir upload
[[email protected] upload]# chmod-r 777/home/upload then modify vsftp config file vsftpd.conf file
[[email protected] upload]# vi/etc/vsftpd/vsftpd.conf on last add local_root=/home/upload save, then restart VSFTPD server program.
Configuration is complete, you can upload files via FTP to the/home/upload directory.
Linux (CENTOS6) build FTP server