vsftpd 错误 530 使用有效凭据时发生登录不正确错误

vsftpd 错误 530 使用有效凭据时发生登录不正确错误

虽然存在许多类似的现有问题/答案引用vsftpd和错误代码530,但它们在这种情况下似乎没有帮助:

情况是,RHEL 6(CentOS 6)上正在运行的 vsftpd-2.2.2-24.el6.x86_64 实例正在迁移到 RHEL 7(CentOS 7)服务器。

在 的配置文件中vsftpd,仅修改了这些:

  • /etc/vsftpd.chroot_list添加本地用户名。
  • /etc/vsftpd/vsftpd.conf

配置如下,(*)表示对分发默认值的更改或添加:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
ftpd_banner=Hello.
listen=YES (*)
listen_ipv6=NO (*)
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
dual_log_enable=YES
use_localtime=YES (*)
rsa_cert_file=/etc/httpd/conf/ssl/vsftpd.crt (*)
rsa_private_key_file=/etc/httpd/conf/ssl/vsftpd.key (*)
ssl_enable=YES (*)
allow_anon_ssl=NO (*)
force_local_data_ssl=NO (*)
force_local_logins_ssl=NO (*)
ssl_tlsv1=YES (*)
ssl_sslv2=NO (*)
ssl_sslv3=NO (*)
require_ssl_reuse=NO (*)
ssl_ciphers=HIGH (*)
ssl_tlsv1_1=YES (*)
ssl_tlsv1_2=YES (*)
allow_writeable_chroot=YES (*)

这是强调该配置是从工作vsftpd实例移植而来的。

启用并(重新)启动服务后,没有报告问题:

 $ sudo systemctl status vsftpd
 $ sudo systemctl enable vsftpd
 $ sudo systemctl start vsftpd
 $ sudo systemctl -l status vsftpd

尝试测试服务器:

$ cd ~ ; \
  TEST="${HOME}/tmp/vsftpd_tst.`date +%Y%m%d%H%M`"; \
  date >${TEST} ; \
  curl -v -k -u ${USER} -ftp-ssl -T ${TEST} ftp://host.domain.tld/

Enter host password for user 'xxxx':
* STATE: INIT => CONNECT handle 0x600069c60; line 1418 (connection #-5000)
* Added connection 0. The cache now contains 1 members
*   Trying host.domain.tld ...
* TCP_NODELAY set
* STATE: CONNECT => WAITCONNECT handle 0x600069c60; line 1470 (connection #0)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connected to host.domain.tld (x.x.x.x) port 21 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600069c60; line 158 7 (connection #0)
* Marked for [keep alive]: FTP default
* FTP 0x60006fe40 (line 3113) state change from STOP to WAIT220
* STATE: SENDPROTOCONNECT => PROTOCONNECT handle 0x600069c60; line 16 01 (connection #0)
< 220 Hello.
> USER xxxx
* FTP 0x60006fe40 (line 801) state change from WAIT220 to USER
< 331 Please specify the password.
> PASS xxxxxxxxxxxx
* FTP 0x60006fe40 (line 2541) state change from USER to PASS
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
< 530 Login incorrect.
* Access denied: 530
* multi_done
* Marked for [closure]: FTP ended with bad error code
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
* Closing connection 0
* The cache now contains 0 members
curl: (67) Access denied: 530

凭证是已知且正确的。

答案1

如果服务器启用了 SELinux,则 SELinux 可能值得怀疑。在本例中,新旧服务器都安装了 SELinux,但旧服务器没有强制执行。

如下图所示,在httpd配置空间中定位 .crt 和 .key 文件似乎导致了一个问题:

$ sudo audit2allow -w -a
...
type=AVC msg=audit(1532728647.463:74431): avc:  denied  { getattr } for pid=48253 comm="vsftpd" path="/etc/httpd/conf/ssl/vsftpd.crt" dev="dm-2" ino=6687286 scontext=system_u:system_r:ftpd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:httpd_config_t:s0 tclass=file

        Was caused by:
        The boolean ftpd_full_access was set incorrectly.
        Description:
        Allow ftpd to full access

        Allow access by executing:
        # setsebool -P ftpd_full_access 1
...

不幸的是,在这种情况下,虽然这个建议很有用,但却还不够。

$ sudo setsebool -P ftpd_full_access 1

故障持续发生,并audit2allow显示出问题,但没有关于运行特定命令的建议。

$ sudo audit2allow -w -a
...
type=AVC msg=audit(1532728647.463:74431): avc:  denied  { getattr } for pid=48253 comm="vsftpd" path="/etc/httpd/conf/ssl/com_vsftpd.crt" dev="dm-2" no=6687286 scontext=system_u:system_r:ftpd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:httpd_config_t:s0 tclass=file

          Was caused by:
          Unknown - would be allowed by active policy
          Possible mismatch between this policy and the one under which
            the audit message was generated.

          Possible mismatch between current in-memory boolean settings
            vs. permanent ones.

这个问题已经得到解决:

$ sudo semodule -R

相关内容