Table of contents
1. FTP service 1. FTP contract introduction
FTP is a file transfer contract. It is a TCP-based contract and adopts the customer/server model. Through the FTP contract, users can upload or download files on the FTP server.
Use ports TCP 20 and 21:
Port 20: used to build data connections and transfer file data.
21 port: used to build control connections.
Disadvantages: Data cannot be automatically synchronized and needs to be automatically synchronized.
2. FTP service principle
FTP services are divided into 2 typeslinux adds ftp servicelinux operating system version, active connection and passive connection.
Active connection principle:
Passive connection principle:
3. Configuration file path
Service configuration file:/etc/vsftpd/vsftpd.conf
Blacklist configuration file:/etc/vsftpd/user_list
Default root directory of anonymous user FTP service: /var/ftp
Default root directory of local user FTP service: /home/Account file with the same name
Error log path:/var/log/messages
2. FTP server setup 1. Build environment
centos7.4 system virtual machine onelinux add ftp service, configure to turn off the firewall and selinux.
systemctlstopfirewalld #关闭防火墙 setenforce0#关闭selinux
2. Detect the environment and install the ftp service
rpa -q vsftpd#检查是否安装ftp服务 yum-y installvsftpd#安装ftp服务
3. Back up the configuration file and add users
useraddlisi #添加lisi用户 useraddliwu #添加liwu用户 echo '123456' |passwd --stdinlisi #设置账户lisi的密码为123456 echo '123456' |passwd --stdinliwu #设置账户lisi的密码为123456 cd/etc/vsftpd/ #进入ftp配置文件目录 cp vsftpd.conf vsftpd.conf.bak#备份配置文件
4. FTP configuration file analysis
anonymous_enable=YES #允许匿名用户访问(账户名为ftp,不需要密码),默认允许建议关闭 local_enable=YES #允许本地用户访问(本地可登录账户) write_enable=YES #开放服务器的写权限,上传文件到服务器必须开启,默认开启 local_umask=022 #本地用户文件权限反掩码,文件权限777-umask,文件权限666-umask dirmessage_enable=YES #开启日志消息,默认开启 xferlog_enable=YES #开启上传现在日志,默认开启 connect_from_port_20=YES #确保端口数据传输来自20端口,默认开启 xferlog_std_format=YES #日志文件设置为标准ftpd xferlog格式,默认开启,日志位置/var/log/xferlog chroot_local_user=YES #将用户访问权限限制在用户自己的根目录下,默认关闭。 allow_writeable_chroot=YES #允许被限制用户对自己根目录进行写操作 anon_root=/var #设置本地用户的默认根目录为/var,注意需要此目录给其他用户读写权限才可上传下载 userlist_enable=YES #开启user_list用户列表,文件位置/etc/vsftpd/user_list,默认关闭 userlist_deny=YES #若user_list是开启状态userlist_deny=YES是黑名单文件中的用户不能登录,默认关闭 #若user_list是开启状态,userlist_deny=NO则只允许user_list中的用户登录
5. Configure local users to access ftp
6. Enable ftp service
systemctlstartvsftpd #开启vsftpd服务 systemctlstatus vsftpd #查看vsftpd服务状态
7. Verification service
①Configure read and write permissions for other users in the /mnt directory
chmod766 -R /mnt #修改/mnt目录用户其他权限具有读写权限
② Configure the liwu user into the user_list file in the blacklist, the file location is /etc/vsftpd/user_list
③Create an a.txt file under /mnt with the content of 123
④Open your own windows computer cmd window and enter the ftp server IP to log in with the account password
⑤The file path downloaded to the local area is under C:Users
⑥Delete the a.txt under /mnt and upload the local a.txt.
⑦. Use blacklist user liwu to try to log in
8. Troubleshooting ideas
①First check whether the local firewall, ftp firewall and selinux are turned off
②Check the configuration file content for errors
③ Check whether the service status is normal. Linux restart command. If it is not normal, check the /var/log/messages log for troubleshooting.
④The default root directory of anonymous users cannot have read permissions, otherwise they will not be able to connect to the ftp server
⑤You can get but cannot put to view the permissions and ownership of the root directory
The above is the detailed content of Use FTP server user liwu to try to log in. 8. Troubleshooting ideas. For more information, please follow other related articles on the PHP Chinese website!