记一次ftp错误

在一个ftp上,突然登不上 报错,使用浏览器登录,报此用户不是私密连接,然后使用服务器客户端登录尝试,错误信息如下:

[root@test ~]# ftp *.*.*.*
Connected to *.*.*.* (*.*.*.*).
220 (vsFTPd 3.0.2)
Name (*.*.*.*:root): ftpuser
331 Please specify the password.
Password:
530 Login incorrect.   #530错误
Login failed.
ftp> exit

去服务端排错

检查配置文件

[root@localhost data]# cat /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=077
dirmessage_enable=YES
xferlog_enable=YES
xferlog_file=/var/log/xferlog
chroot_local_user=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

 查看/etc/pam.d/vsftpd

[root@localhost ~]# vim  /etc/pam.d/vsftpd 

#%PAM-1.0
session    optional     pam_keyinit.so    force revoke
auth       required    pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
auth       required    pam_shells.so
auth       include    password-auth
account    include    password-auth
session    required     pam_loginuid.so
session    include    password-auth

 [root@localhost ~]# vim /etc/vsftpd/ftpusers

# Users that are not allowed to login via ftp
root
bin
#daemon   #注释掉
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

[root@localhost ~]# systemctl restart  vsftpd 

尝试

[root@test ~]# ftp *.*.*.*
Connected to *.*.*.* (*.*.*.*).
220 (vsFTPd 3.0.2)
Name (*.*.*.*:root): ftpuser
331 Please specify the password.
Password:
500 OOPS: vsftpd: refusing to run with writable root inside chroot()    #报500错误
Login failed.
421 Service not available, remote server has closed connection
ftp> exit

新的错误原因是因为我们限定了用户不能跳出其主目录之后,使用该用户登录FTP时往往会遇到这个错误

 这个问题是由于在2.3.5之后,vsftpd增强了安全检查,如果用户被限定在了其主目录下,则该用户的主目录不能再具有写权限了!如果检查发现还有写权限,就会报该错误。

 要修复这个错误,可以用命令chmod a-w /home/user去除用户主目录的写权限,注意把目录替换成你自己的。或者你可以在vsftpd的配置文件中增加下列两项中的一项: 

allow_writeable_chroot=YES   #增加对自己家目录的写权限

然后查看自己服务器的目录权限

[root@localhost ~]# ll /data/

drwsrwsrwt. 7 root root 76 Apr  3 11:28 ftp      #权限问题

修改权限:

[root@localhost ~]# chmod u-s  /data/ftp
[root@localhost ~]# chmod g-s  /data/ftp
[root@localhost ~]# chmod o-t  /data/ftp
[root@localhost ~]# chmod u-w  /data/ftp
[root@localhost ~]# chmod g-w  /data/ftp
[root@localhost ~]# chmod o-w  /data/ftp
[root@localhost ~]# ll  /data/ftp
dr-xr-xr-x. 7 root root 76 Apr  3 11:28 ftp

重新登录

[root@test ~]# ftp *.*.*.*
Connected to *.*.*.* (*.*.*.*).
220 (vsFTPd 3.0.2)
Name (*.*.*.*:root): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.ftp> ls
227 Entering Passive Mode (*,*,*,*,69,228).
150 Here comes the directory listing.
drwxrwxrwx   10 0        0            4096 Apr 03 03:20 nginx1
drwxrwxrwx   11 0        0            4096 Feb 28 10:07 nginx2
drwxrwxrwx   10 0        0            4096 Feb 28 10:12 nginx3
drwxrwxrwx   10 0        0            4096 Apr 06 06:36 nginx4
drwxrwxrwx   10 0        0            4096 Apr 03 03:28 nginx5
226 Directory send OK.
ftp> exit
221 Goodbye.

成功登陆,问题解决!!!

猜你喜欢

转载自www.cnblogs.com/zyxnhr/p/10664994.html
今日推荐