如果没有则通过yarm源进行安装
进入到ftp的根目录默认是/etc/vsftpd/文件中进行配置
[root@htuidc ~]# tree /etc/vsftpd/ /etc/vsftpd/ ├── chroot_list #自建的允许切换用户清单 ├── ftpusers #ftpusers配置文件,在里面的用户禁止使用ftp登陆 ├── user_list #文件禁止登录FTP的用户 ├── vsftpd.conf #主配置文件 └── vsftpd_conf_migrate.sh /etc/vsftpd/vsftpd.conf:vsftpd 的核心配置文件 /etc/vsftpd/ftpusers:用于指定哪些用户不能访问FTP 服务器。 黑名单 /etc/vsftpd/user_list:指定允许使用vsftpd 的用户列表文件。 白名单 /etc/vsftpd/chroot_list:指定允许使用vsftpd 的用户列表文件。 控制名单下的目录能不能离开ftp根目录vsftpd.conf具体配置如下:
anonymous_enable=NO #允许匿名用户访问为了安全选择关闭 local_enable=YES # 允许本地用户登录 write_enable=YES # 是否允许写入 local_umask=022 # 本地用户上传文件的umask dirmessage_enable=YES #为YES则进入目录时显示此目录下由message_file选项指定的文本文件(,默认为.message)的内容 xferlog_enable=YES #开启日志 xferlog_std_format=YES #标准格式 connect_from_port_20=YES xferlog_file=/var/log/xferlog #ftp日志目录 idle_session_timeout=6000 #设置客户端连接时间 data_connection_timeout=1200 #设置数据连接时间 针对上传,下载 chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list #设置为YES则下面的控制有效 chroot_list_enable=YES #若为NO,则记录在chroot_list_file所指定的文件(默认是/etc/vsftpd.chroot_list)中的用户将被chroot在登录后所在目录中,无法离开.如果为YES,则所记录的用户将不被chroot.这里YES. chroot_local_user=YES userlist_deny=NO #若设置为YES则记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)中的用户将无法login,并且将检察下面的userlist_deny选项 userlist_enable=YES #若为NO,则仅接受记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)中的用户的login请求.若为YES则不接受这些用户的请求. userlist_file=/etc/vsftpd/user_list #白名单 chroot_list_enable=YES local_root=/var/ftp/pub #根目录 listen=NO listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES3、创建白名单
useradd xxx passwd xxx 并添加到user_list和chroot_list中去4、关闭防火墙
systemctl stop firewalld.service5.启动ftp服务器
systemctl enable vsftpd.service #开机自启 systemctl restart vsftpd.service #启动6.赋权,将ftp指定的根目录赋权为777权限
chmod 777 /var/ftp/pub运行以下命令查看 FTP 服务端口
[root@node1 sbin]# netstat -antup|grep ftp tcp6 0 0 :::21 :::* LISTEN 24196/vsftpd [root@node1 sbin]#配置本地用户登录
1.启动后ftp指令找不到 这是由于ftp为vsftp的客户端,需要单独安装
yum search ftp [root@node1 ~]# yum search ftp yum install - y ftp.x86_642.Unregistered Authentication Agent for unix-process
[root@node1 sbin]# journalctl -xe -- Unit session-98.scope has finished starting up. -- -- The start-up result is done. Jul 01 00:01:02 node1.bigdata.com CROND[24151]: (root) CMD (run-parts /etc/cron.hourly) Jul 01 00:01:02 node1.bigdata.com systemd[1]: Starting Session 98 of user root. -- Subject: Unit session-98.scope has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit session-98.scope has begun starting up. Jul 01 00:01:02 node1.bigdata.com run-parts(/etc/cron.hourly)[24154]: starting 0anacron Jul 01 00:01:02 node1.bigdata.com anacron[24160]: Anacron started on 2020-07-01 Jul 01 00:01:02 node1.bigdata.com anacron[24160]: Normal exit (0 jobs run) Jul 01 00:01:02 node1.bigdata.com run-parts(/etc/cron.hourly)[24162]: finished 0anacron Jul 01 00:02:59 node1.bigdata.com polkitd[627]: Registered Authentication Agent for unix-process:24169:4815557 (system bus name :1.221 [/usr/bin/pkttyage Jul 01 00:02:59 node1.bigdata.com systemd[1]: Starting Vsftpd ftp daemon... -- Subject: Unit vsftpd.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit vsftpd.service has begun starting up. Jul 01 00:02:59 node1.bigdata.com polkitd[627]: Unregistered Authentication Agent for unix-process:24169:4815557 (system bus name :1.221, object path /or Jul 01 00:02:59 node1.bigdata.com systemd[1]: vsftpd.service: control process exited, code=exited status=2 Jul 01 00:02:59 node1.bigdata.com systemd[1]: Failed to start Vsftpd ftp daemon. -- Subject: Unit vsftpd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit vsftpd.service has failed. -- -- The result is failed. Jul 01 00:02:59 node1.bigdata.com vsftpd[24175]: 500 OOPS: run two copies of vsftpd for IPv4 and IPv6 Jul 01 00:02:59 node1.bigdata.com systemd[1]: Unit vsftpd.service entered failed state. Jul 01 00:02:59 node1.bigdata.com systemd[1]: vsftpd.service failed.500 OOPS: run two copies of vsftpd for IPv4 and IPv6
# # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. #一定要关掉,因为下面ipv6已经包含了 listen=NO # # This directive enables listening on IPv6 sockets. By default, listening # on the IPv6 "any" address (::) will accept connections from both IPv6 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 # sockets. If you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. # Make sure, that one of the listen options is commented !! #确保,注释掉了一个listen选项 listen_ipv6=YES3.在能ping通的情况下,链接不上ftp
ftp ip 重启ftp所在机器,成功链接