问题

用户通过 ftp 登录到 vsftpd 服务器时出现错误“530:权限被拒绝”
Vsftp 服务器是新安装的并已启动,但某些用户无法访问,出现如下所示的错误。

# service vsftpd status
vsftpd (pid 5806) is running...
# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:oracle): user
530 Permission denied.
Login failed.

允许 VSFTP 服务器本地用户登录

  1. 编辑 /etc/vsftpd/vsftpd.conf 并将 userlist_enable 设置为 YES 并将 userlist_deny 设置为 NO 。
# vi /etc/vsftpd/vsftpd.conf
userlist_enable=YES
userlist_deny=NO
  1. 修改 /etc/vsftpd/user_list ,将允许登录的用户(user01)放入该文件
# cat  /etc/vsftpd/user_list
user01
  1. 将所有不允许 ftp 的用户放在 /etc/vsftpd/ftpusers 中。
# cat ftpusers
# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
  1. 重启vsftpd服务。
# service vsftpd restart
  1. 再次尝试使用用户 user01 进行 ftp。
$ ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): user01
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
  1. 还可以尝试使用不允许的用户 ID 登录,例如 root。
# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): root
530 Permission denied.
Login failed.
ftp>
https://onitroad.com 更多教程

解决方案

原因是如果文件 /etc/vsftpd/vsftpd.conf 中的参数 userlist_enable 是 YES 并且参数 userlist_deny 默认值也是 YES ,那么文件 /etc/vsftpd/user_list 中的用户名将得到 '530 Permission denied' 错误和甚至不提示输入密码。

当启用参数 userlist_enable 时,vsftpd 将加载文件 /etc/vsftpd/userlist_file 中的用户名。
如果用户尝试使用此文件中的名称登录,他们将在被要求输入密码之前被拒绝。
这可能有助于防止传输明文密码。

如果 userlist_enable 被激活,将检查参数 userlist_deny。
如果将此设置设置为 NO,则当用户在文件 /etc/vsftpd/userlist_file 中列出时,他们将被允许登录。

注意:出于安全原因,userlist_enable 应该设置为“YES”,因为这个问题也可以通过在 /etc/vsftpd/vsftpd.conf 中设置“userlist_enable=NO”来解决

因此,我们可以通过在激活 userlist_enable 时将 userlist_deny 设置为 NO 来解决此问题。
然后将允许的用户名放在文件 /etc/vsftpd/user_list 中,将不允许的用户名放在文件 /etc/vsftpd/ftpusers 中。

你可以在 vsftpd.conf 的手册中看到解释。

$ man  vsftpd.conf
userlist_deny
              This  option  is  examined if userlist_enable is activated. If you set this setting to NO, then users will be
              denied login unless they are explicitly listed in the file specified by userlist_file.  When login is denied,
              the denial is issued before the user is asked for a password.
userlist_enable
              If  enabled, vsftpd will load a list of usernames, from the filename given by userlist_file.  If a user tries
              to log in using a name in this file, they will be denied before they are asked for a password.  This  may  be
              useful in preventing cleartext passwords being transmitted. See also userlist_deny.
              Default: NO

我们还可以在文件 /etc/vsftpd/user_list 中看到这些注释。

# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
ftp 530: permission denied
日期:2020-09-17 00:13:04 来源:oir作者:oir