Bug 4514 - [Anolis23-iso][anck][x86_64]vsftpd搭建ftp服务器不能使用虚拟账户登录
Summary: [Anolis23-iso][anck][x86_64]vsftpd搭建ftp服务器不能使用虚拟账户登录
Status: RESOLVED FIXED
Alias: None
Product: Anolis OS 23
Classification: Anolis OS
Component: BaseOS Packages (show other bugs) BaseOS Packages
Version: 23.0
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: happy_orange
QA Contact: bolong_tbl
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-14 15:54 UTC by gitpush
Modified: 2023-06-17 15:49 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gitpush alibaba_cloud_group 2023-03-14 15:54:49 UTC
anolis 23上vsftpd搭建ftp服务器不能使用虚拟账户登录,anolis 8上可以登录
查看日志信息 tail /var/log/secure
报错信息:pam_userdb(vsftpd:auth): user_lookup: could not open database `/etc/vsftpd/loginusers': No such file or directory
测试流程:
1、新建/etc/vsftpd/loginusers,输入虚拟用户登录名和密码
2、使用开启虚拟用户登录 ,如 useradd vsftpd -d /vsftpd -s /bin/false
3、创建虚拟用户主目录 mkdir -p /vsftpd/ftp1/
4、设置权限 chown -R vsftpd /vsftpd/*
5、创建数据库文件 
   db_load -T -t hash -f /etc/vsftpd/loginusers /etc/vsftpd/loginusers.db
   chmod 600 /etc/vsftpd/loginusers.db
   chmod 600 /etc/vsftpd/loginusers
6、启用数据库文件,如下
cat > /etc/pam.d/vsftpd <<EOF
#%PAM-1.0
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/loginusers
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/loginusers
EOF
7、创建虚拟用户配置文件
   mkdir -p /etc/vsftpd/userconf
   cat > /etc/vsftpd/userconf/ftp1 <<EOF
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
EOF
8、修改配置文件/etc/vsftpd/vsftpd.conf
  增加pasv_enable=YES
      guest_enable=YES
      guest_username=vsftpd
      allow_writeable_chroot=YES
      anon_mkdir_write_enable=YES
  修改anonymous_enable=YES
      listen=YES
      listen_ipv6=NO
9、重启服务service vsftpd restart
10、tail /var/log/secure 查看报错
11、登录过程
[root@iZbp1b84oc3eixf4mk1q80Z anolis-pkg-tests]# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 (vsFTPd 3.0.3)
Name (127.0.0.1:root): ftp1
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
ftp> exit
Comment 1 gitpush alibaba_cloud_group 2023-03-14 15:59:05 UTC
环境:
[root@iZbp1b84oc3eixf4mk1q80Z anolis-pkg-tests]# cat /etc/os-release
NAME="Anolis OS"
VERSION="23"
ID="anolis"
VERSION_ID="23"
PLATFORM_ID="platform:an23"
PRETTY_NAME="Anolis OS 23"
ANSI_COLOR="0;31"
HOME_URL="https://openanolis.cn/"
BUG_REPORT_URL="https://bugzilla.openanolis.cn/"

软件包:
[root@iZbp1b84oc3eixf4mk1q80Z anolis-pkg-tests]# yum info vsftpd ftp libdb-utils
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:33:37 ago on Tue Mar 14 15:24:47 2023.
Installed Packages
Name         : ftp
Version      : 0.17
Release      : 2.an23
Architecture : x86_64
Size         : 104 k
Source       : ftp-0.17-2.an23.src.rpm
Repository   : @System
From repo    : AppStream-Test
Summary      : The standard UNIX FTP (File Transfer Protocol) client
URL          : ftp://ftp.linux.org.uk/pub/linux/Networking/netkit
License      : BSD with advertising
Description  : The ftp package provides the standard UNIX command-line FTP (File
             : Transfer Protocol) client.  FTP is a widely used protocol for
             : transferring files over the Internet and for archiving files.
             :
             : If your system is on a network, you should install ftp in order to do
             : file transfers.

Name         : libdb-utils
Version      : 5.3.28
Release      : 51.fc36
Architecture : x86_64
Size         : 356 k
Source       : libdb-5.3.28-51.fc36.src.rpm
Repository   : @System
From repo    : build
Summary      : Command line tools for managing Berkeley DB databases
URL          : http://www.oracle.com/database/berkeley-db/
License      : BSD and LGPLv2 and Sleepycat
Description  : The Berkeley Database (Berkeley DB) is a programmatic toolkit that
             : provides embedded database support for both traditional and
             : client/server applications. Berkeley DB includes B+tree, Extended
             : Linear Hashing, Fixed and Variable-length record access methods,
             : transactions, locking, logging, shared memory caching, and database
             : recovery. DB supports C, C++ and Perl APIs.

Name         : vsftpd
Version      : 3.0.3
Release      : 50.fc36
Architecture : x86_64
Size         : 348 k
Source       : vsftpd-3.0.3-50.fc36.src.rpm
Repository   : @System
From repo    : build
Summary      : Very Secure Ftp Daemon
URL          : https://security.appspot.com/vsftpd.html
License      : GPLv2 with exceptions
Description  : vsftpd is a Very Secure FTP daemon. It was written completely from
             : scratch.
Comment 2 扣肉 2023-06-13 07:45:07 UTC
请使用 龙蜥仓库中的vsftpd软件包进行测试
Comment 3 happy_orange alibaba_cloud_group 2023-06-17 15:49:44 UTC
vsftpd 在最新 23 nightly 镜像里已经提供,请重新测试。