Centos7安装FTP服务(踩坑总结篇)

**

更新时间:2020-08-24

**

此教程为centos7安装配置ftp踩过的坑。
目的:新建账号可对文件进行上传,下载。删除。
下面给了:
配置全过程。报错查找过程。新建账号步骤

配置路上非常坎坷。

参考:

1.配置匿名用户
2.自定义用户版
3.创建FTP账号
4.FTP服务部署,这个讲的比较详细
5.PAM模块详解

照着完成上面1和2的操作。
3.4.5的文章都可以看看。

一般来说,第一个匿名登录没啥问题。
问题是第二个新建用户。
会因为配置文件没配好,或者是什么幺蛾子的东西。
错误原因一般有:
1.配置文件没有配置好
每次修改配置文件后,需要重新启动vsftp
2.文件夹的权限没有给


常用命令:

```cpp
systemctl start vsftpd.service  启动vsftpd

systemctl stop vsftpd.service  停止vsftpd

systemctl restart vsftpd.service  重启vsftpd

systemctl start firewalld   开启防火墙

FTP登录失败解决方案:
530 Login incorrect
参考:第一种解决方案
第二种解决方案

查看FTP日志:
tail -f /var/log/secure
常见报错:
Aug 24 16:34:18 localhost unix_chkpwd[7648]: password check failed for user (test)
Aug 24 16:34:18 localhost vsftpd: pam_unix(vsftpd:auth): authentication failure; logname= uid=0 euid=0 tty=ftp ruser=test rhost=localhost user=test
这个是密码错误,重设密码后即可解决。

可根据错误信息百度寻找对应解决方案

ftp文件描述:
如果是默认安装vsftpd的话,以下是一些文件的位置约定:
/usr/sbin/vsftpd ---- VSFTPD的主程序
/etc/rc.d/init.d/vsftpd ---- 启动脚本
/etc/vsftpd/vsftpd.conf ---- 主配置文件
/etc/pam.d/vsftpd ---- PAM认证文件
/etc/vsftpd.ftpusers ---- 禁止使用VSFTPD的用户列表文件
/etc/vsftpd.user_list ---- 禁止或允许使用VSFTPD的用户列表文件
/var/ftp ---- 匿名用户主目录
/var/ftp/pub ---- 匿名用户的下载目录

匿名账号登录配置:

anonymous_enable=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES

这个配置需要自己加上去
pam_service_name=vsftpd

下面给出我的conf文件:这是成功的

# 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
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


#userlist_file=/etc/vsftpd/user_list
allow_writeable_chroot=YES





**新增FTP账号用户**
(自己操作的方式,没问题,有问题发生请回到头部)
```cpp
//新建访问文件夹
mkdir /var/www/testPath
//给文件夹访问权限
chmod -R 777 /var/www/testPath/
//新建用户和指定访问的路径
useradd -d /var/www/testPath testTwo
//设置或修改用户密码
passwd testTwo
//查看新创建的用户的信息:
tail /etc/passwd
//登录ftp
ftp localhost
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值