1、ftp安装
[root@rabbitMQ1 ~]# yum -y install vsftpd
2、ftp配置
#设置开机自启
[root@rabbitMQ1 ~]# systemctl enable vsftpd
#conf配置
[root@rabbitMQ1 ~]# vim /etc/vsftpd/vsftpd.conf
pam_service_name=vsftpd
# 允许本地用户登录
local_enable=YES
# 允许用户上传文件
write_enable=YES
# 禁止匿名用户登录
anonymous_enable=NO
# 限制用户只能访问其主目录
chroot_local_user=YES
allow_writeable_chroot=YES
# 允许被动模式(用于客户端连接)
pasv_enable=YES
pasv_min_port=10000
pasv_max_port=10100
# 日志文件
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
#启用用户列表功能
userlist_enable=YES
userlist_deny=YES
#userlist_deny=YES /etc/vsftpd/user_list 中的用户将被拒绝访问 FTP 服务器
直接复制上述配置即可
3、创建ftp用户
[root@rabbitMQ1 ~]# useradd -m zjp
[root@rabbitMQ1 ~]# passwd zjp
#设置主目录权限
[root@rabbitMQ1 ~]# chmod 755 /home/zjp
我设置密码为zjp
4、启动服务
[root@rabbitMQ1 ~]# systemctl start vsftpd.service
5、验证,访问ftp、下载内容
注意:如果没有在配置文件设置可以匿名访问,则无法直接访问ftp地址
[root@rabbitMQ1 ~]# ftp 10.211.55.57
Connected to 10.211.55.57 (10.211.55.57).
220 (vsFTPd 3.0.5)
Name (10.211.55.57:root): zjp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (10,211,55,57,39,30).
150 Here comes the directory listing.
drwxr-xr-x 2 1004 1004 6 Feb 11 00:46 zjp
226 Directory send OK.
6、ftp 登录提示530 Login incorrect解决办法
1、先确保用户能够登录(若使用无法登录的用户,则需要在 /etc/shells文件添加对应用户的shell,如/sbin/nologin,或者直接修改回bash)
usermod -s /bin/bash 用户
2、检查/etc/vsftpd/vsftpd.conf配置(可直接复制上述配置)
3、根据上述配置,再检查/etc/vsftpd/user_list中不存在需要登录的用户