Linux小玩意之 在RHEL8 上配置vsftp 服务

1 环境

  • Red Hat Enterprise Linux release 8.2 (Ootpa)
  • vsftpd-3.0.3-32.el8.x86_64

2 配置步骤

2.1 建立ftp 用户并更新密码

1
# useradd -d /mnt/oostech_ftp -s /bin/nologin oostechftp && echo 'samlee:oostechftp' | chpasswd

2.2 给目录修改权限

1
# chown -R oostechftp:oostechftp /mnt/oostech_ftp

2.3 修改 vsftp 的pam 配置

1
2
3
# cat /etc/pam.d/vsftpd
#%PAM-1.0
#auth required pam_shells.so

2.4 建立vsftp 配置文件(可以先将原来的备份,然后新建一份/etc/vsftpd/vsftpd.conf)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
anonymous_enable=NO
ftpd_banner=Welcome to oosTech 文件共享 FTP
local_enable=YES
write_enable=YES
local_umask=022
virtual_use_local_privs=YES
guest_enable=YES
guest_username=oostechftp
local_root=/mnt/oostech_ftp
chroot_local_user=YES
chroot_list_enable=YES
listen=YES
pam_service_name=vsftpd
allow_writeable_chroot=YES

附录 1 关于 550 Permission denied 错误

  • 错误信息
    1
    2
    3
    4
    ftp> put Makefile
    local: Makefile remote: Makefile
    227 Entering Passive Mode (150,150,150,30,190,88).
    550 Permission denied.
  • 修复 (必须在 /etc/vsftpd/vsftpd.conf 配上)
    1
    virtual_use_local_privs=YES
  • 验证
    1
    2
    3
    4
    5
    6
    7
    ftp> put Makefile
    local: Makefile remote: Makefile
    227 Entering Passive Mode (150,150,150,30,127,153).
    150 Ok to send data.
    226 Transfer complete.
    849 bytes sent in 0.00203 secs (417.61 Kbytes/sec)
    ftp>