文档章节

CentOS 7 x64 安装FTP服务器

聆风阁主
 聆风阁主
发布于 2018/12/13 13:36
字数 1322
阅读 41
收藏 0

一、安装vsftpd软件

yum install vsftpd

二、创建FTP本地用户

useradd -g ftp -s /sbin/nologin ftpuser  # 创建登录用户
passwd ftpuser                           # 修改用户密码

三、设置防火墙白名单

firewall-cmd --add-service=ftp  # 允许ftp服务通过

四、查看SELinux的ftp相关配置项

[root@host100 ~]# getsebool -a | grep ftp  # 查看ftp相关配置项
ftpd_anon_write --> off
ftpd_connect_all_unreserved --> off
ftpd_connect_db --> off
ftpd_full_access --> off
ftpd_use_cifs --> off
ftpd_use_fusefs --> off
ftpd_use_nfs --> off
ftpd_use_passive_mode --> off
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off

五、开启ftpd_full_access配置

setsebool ftpd_full_access on

六、查看SELinux的ftp相关配置项

[root@host100 ~]# getsebool -a | grep ftp  # 查看ftp相关配置项
ftpd_anon_write --> off
ftpd_connect_all_unreserved --> off
ftpd_connect_db --> off
ftpd_full_access --> on
ftpd_use_cifs --> off
ftpd_use_fusefs --> off
ftpd_use_nfs --> off
ftpd_use_passive_mode --> off
httpd_can_connect_ftp --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_home_dir --> off

七、编辑vsftpd配置文件

vi /etc/vsftpd/vsftpd.conf

修改以下几点:

anonymous_enable=NO          # 禁用匿名用户

chroot_local_user=YES        # 将用户锁定在自己的主目录下,不可访问其它目录
allow_writeable_chroot=YES

配置文件如下:

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
allow_writeable_chroot=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# 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.
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_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

八、启动vsftpd服务

systemctl start vsftpd.service

常用命令:

systemctl start vsftpd.service    # 启动服务
systemctl restart vsftpd.service  # 重启服务
systemctl stop vsftpd.service     # 停止服务

九、测试安装是否成功

浏览器访问:ftp://181.111.111.100/ftp://ip)

命令提示符访问:

Microsoft Windows [版本 10.0.17134.407]
(c) 2018 Microsoft Corporation。保留所有权利。

C:\Users\ThinkPad>ftp 181.111.111.100
连接到 181.111.111.100。
220 (vsFTPd 3.0.2)
200 Always in UTF8 mode.
用户(181.111.111.100:(none)): ftpuser
331 Please specify the password.
密码:
230 Login successful.
ftp> put D://ftptest.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 发送 16 字节,用时 0.00秒 16000.00千字节/秒。
ftp> mkdir ftpfiles
257 "/ftpfiles" created
ftp> cd ftpfiles
250 Directory successfully changed.
ftp> put D://ftptest.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 发送 16 字节,用时 0.00秒 16000.00千字节/秒。
ftp> get ftptest.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for ftptest.txt (16 bytes).
226 Transfer complete.
ftp: 收到 16 字节,用时 0.00秒 16000.00千字节/秒。
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
ftptest.txt
226 Directory send OK.
ftp: 收到 16 字节,用时 0.00秒 4.00千字节/秒。
ftp>

© 著作权归作者所有

聆风阁主
粉丝 0
博文 19
码字总数 16521
作品 0
福州
私信 提问
centos 6.5 YUM安装软件 错误提示 No more mirrors to try. 如何解决

centos 6.5 YUM安装软件 错误提示 No more mirrors to try. 如何解决 在Centos6.5中,使用yum安装openstack时候报错:[Errno 256] No more mirrors to try.,本文我们来分析这个错误,及提供...

Jack崔
2017/07/27
0
0
建立局域网内使用的CentOS7源

建立局域网内使用的CentOS7源 by 无若 1. 在CentOS下建立匿名的FTP访问服务 CentOS 7下安装配置pure-ftpd,并使用匿名用户登录 Pure-FTPd是Linux上的一个开源的FTP服务程序。 (1). 安装epel源...

无若
2016/08/04
115
0
Linux--批量安装centos

系统约定 OS:Centos 6.2 x64 IP:192.168.0.1 安装方式:采用dhcp+tftp+ftp+kickstart 挂载镜像 #mkdir /media/cdrom #mount /dev/cdrom /media/cdrom 备份本地原来yum源文件 #mkdir /etc/......

nihaozhuxy
2018/06/26
0
0
手机如何连接VMware虚拟机中的服务器

手机如何连接VMware虚拟机中的服务器 由于没有服务器,于是在自己的虚拟机中CentOS 7中安装hadoop中,用手机看是否能否登陆hadoop管理界面 环境 android手机 Windows 10 x64笔记本 VMware W...

lizer2016
2015/12/02
0
0
公司服务器从windows转移到centos 6.2 之中遇到的问题与思考

公司领导决定,将之前的部分windows server服务器,转成LINUX操作系统。选择的LINUX操作系统为centos 6.2 第一步:将新购置的24核DELL服务器装上LINUX系统,另需新装一台 servier2003r264位操...

枫爱若雪
2012/05/07
364
2

没有更多内容

加载失败,请刷新页面

加载更多

64.监控平台介绍 安装zabbix 忘记admin密码

19.1 Linux监控平台介绍 19.2 zabbix监控介绍 19.3/19.4/19.6 安装zabbix 19.5 忘记Admin密码如何做 19.1 Linux监控平台介绍: 常见开源监控软件 ~1.cacti、nagios、zabbix、smokeping、ope...

oschina130111
今天
13
0
当餐饮遇上大数据,嗯真香!

之前去开了一场会,主题是「餐饮领袖新零售峰会」。认真听完了餐饮前辈和新秀们的分享,觉得获益匪浅,把脑子里的核心纪要整理了一下,今天和大家做一个简单的分享,欢迎感兴趣的小伙伴一起交...

数澜科技
今天
7
0
DNS-over-HTTPS 的下一代是 DNS ON BLOCKCHAIN

本文作者:PETER LAI ,是 Diode 的区块链工程师。在进入软件开发领域之前,他主要是在做工商管理相关工作。Peter Lai 也是一位活跃的开源贡献者。目前,他正在与 Diode 团队一起开发基于区块...

红薯
今天
12
0
CC攻击带来的危害我们该如何防御?

随着网络的发展带给我们很多的便利,但是同时也带给我们一些网站安全问题,网络攻击就是常见的网站安全问题。其中作为站长最常见的就是CC攻击,CC攻击是网络攻击方式的一种,是一种比较常见的...

云漫网络Ruan
今天
12
0
实验分析性专业硕士提纲撰写要点

为什么您需要研究论文的提纲? 首先当您进行研究时,您需要聚集许多信息和想法,研究论文提纲可以较好地组织你的想法, 了解您研究资料的流畅度和程度。确保你写作时不会错过任何重要资料以此...

论文辅导员
今天
8
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部