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"/>