Apache ftpServer 配置用户
问题
Apache ftpServer默认配置文件中,使用./res/conf/users.properties
配置用户信息。
<file-user-manager file="./res/conf/users.properties" />
默认有2个用户:管理员admin和匿名用户anonymous。
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # Password is "admin" ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3 ftpserver.user.admin.homedirectory=./res/home ftpserver.user.admin.enableflag=true ftpserver.user.admin.writepermission=true ftpserver.user.admin.maxloginnumber=0 ftpserver.user.admin.maxloginperip=0 ftpserver.user.admin.idletime=0 ftpserver.user.admin.uploadrate=0 ftpserver.user.admin.downloadrate=0 ftpserver.user.anonymous.userpassword= ftpserver.user.anonymous.homedirectory=./res/home ftpserver.user.anonymous.enableflag=true ftpserver.user.anonymous.writepermission=false ftpserver.user.anonymous.maxloginnumber=20 ftpserver.user.anonymous.maxloginperip=2 ftpserver.user.anonymous.idletime=300 ftpserver.user.anonymous.uploadrate=4800 ftpserver.user.anonymous.downloadrate=4800
尝试在该文件继续添加自定义用户。
ftpserver.user.myuser.userpassword=myuser ftpserver.user.myuser.homedirectory=./res/home ftpserver.user.myuser.enableflag=true ftpserver.user.myuser.writepermission=true ftpserver.user.myuser.maxloginnumber=0 ftpserver.user.myuser.maxloginperip=0 ftpserver.user.myuser.idletime=0 ftpserver.user.myuser.uploadrate=0 ftpserver.user.myuser.downloadrate=0
发现客户端无法连接。提示
状态: 正在连接 127.0.0.1:21... 状态: 连接建立,等待欢迎消息... 响应: 220 Service ready for new user. 命令: USER myuser 响应: 331 User name okay, need password for myuser. 命令: PASS ****** 响应: 530 Authentication failed. 错误: 严重错误 错误: 无法连接到服务器
看提示应该是密码不对。但是密码确实是我配置的。
解决方案
在ftpd.xml中配置的<file-user-manager file="./res/conf/users.properties" />加上encrypt-passwords="clear"
<file-user-manager file="./res/conf/users.properties" encrypt-passwords="clear"/>
启动
nohup ./ftpd.sh res/conf/ftpd-typical.xml &