问题描述
本问题基于vsftpd 3.0.5
使用ftp客户端连接vsftpd服务端报错日志及截图如下:
oldsix@OLDSIX:~/work$ ftp root@192.168.69.1
Connected to 192.168.69.1.
500 OOPS: cannot locate user entry:nobody
ftp>
问题截图:
---
原因分析:
1、根据官方源码中的资料解释:
(1)vsftpd3.0.5/INSTALL
vsftpd needs the user "nobody" in the default configuration. Add this
user in case it does not already exist. e.g.:
[root@localhost root]# useradd nobody
useradd: user nobody exists
翻译过来就是:
vsftpd在默认配置中需要用户“nobody”。添加此用户,以防它不存在。例如:
[root@localhostroot]#useradd nobody
(2)vsftpd3.0.5/FAQ
Q) Help! I'm getting the error message "str_getpwnam".
A) The most likely cause of this is that the user that is configured as the
'nopriv_user' setting (often 'nobody') does not exist on your system. vsftpd
needs this user to run bits of itself with no privilege.
(3)vsftpd3.0.5/vsftpd.conf
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
2、通过跟踪源码发现
vsftpd3.0.5/tunables.c
install_str_setting("nobody", &tunable_nopriv_user);
通过跟踪发现
该参数默认为nobody,并存储在全局变量tunable_nopriv_user中,跟踪代码发现
nopriv_user为tunable_nopriv_user配置选项,和vsftpd.conf描述一致。---
解决方案:
根据问题原因可给出以下三个解决方案:
1、vsftpd服务器所在系统增加nobody用户
2、修改/etc/vsftpd.conf配置
nopriv_user=系统中已经存在的用户(cat /etc/passwd )。
3、修改源码(不建议)
vsftpd3.0.5/tunables.c文件中的
install_str_setting("nobody", &tunable_nopriv_user);将nobody
替换为系统中存在的用户。
修改后编译替换原来的vsftpd服务器即可
ps:可通过cat /etc/passwd 查看已存在用户。