centos7.4搭建ftp服务器

1. 准备环境

版本说明
CentOS Linux release 7.4.1708 (Core)cat /etc/redhat-release

2.检查是否已安装vsftpd

[root@node1 opt]# rpm -qa|grep vsftpd

如果没有则通过yarm源进行安装

3.安装配置

yum install -y vsftpd

在这里插入图片描述
进入到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=YES

3、创建白名单

useradd  xxx passwd xxx 并添加到user_list和chroot_list中去

4、关闭防火墙

systemctl stop firewalld.service  

5.启动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]# 

配置本地用户登录

4.文件解决

1.启动后ftp指令找不到
这是由于ftp为vsftp的客户端,需要单独安装

yum search ftp
[root@node1 ~]# yum search ftp
 yum install - y ftp.x86_64

2.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=YES

3.在能ping通的情况下,链接不上ftp

ftp ip
重启ftp所在机器,成功链接
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值