Apache Ftpserver Detailed

Source: Internet
Author: User
Tags ftp file file transfer protocol

FTP is the abbreviation of filetransfer Protocol (File Transfer Protocol), while Chinese is called "Interfax protocol". Used for two-way transmission of control files on the Internet. At the same time, it is also an application (application). There are different FTP applications based on different operating systems, and all of these applications follow the same protocol to transfer files. In the use of FTP, users often encounter two concepts: "Download" (Download) and "Upload" (Upload). A "Download" file is a copy of a file from a remote host to its own computer; the "upload" file is a copy of the file from your computer to a remote host. In the Internet language, users can upload (download) files to (from) remote hosts through the client program.

Here we introduce the Ftpserver under Apache's Mina project:


OK, let's cut to the chase! The detailed steps are as follows:

Mode one: Create Apache ftpserver by loading the file.

1, download Apache Ftpserver, currently, the latest for 1.0.6,:http://mina.apache.org/ftpserver-project/downloads.html

2, decompression to get apache-ftpserver-1.0.6;

3, into the apache-ftpserver-1.0.6\res\conf, to carry out the relevant configuration;

First modify users.properties This file

FTPSERVER.USER.ADMIN.USERPASSWORD=21232F297A57A5A743894A0E4A801FC3 modified to:

Ftpserver.user.admin.userpassword=admin

Then modify the Ftpd-typical.xml file

<file-user-managerfile= "./res/conf/users.properties" > for

<file-user-managerfile= "./res/conf/users.properties" encrypt-passwords = "clear"/>

4, installation and start ftpserver;

Go to cmd command/bin this directory execution (Win7 environment needs to start cmd as Administrator),

Service Install (note: Install only one time)

Ftpd.bat Res/conf/ftpd-typical.xml (if you see the phrase "Ftpserver started", which means ftpserver boot success)


5. Login Apache Ftpserver

Open the browser, enter: Ftp://hostaddress:port, such as: ftp://10.0.0.132:2121, login ftp file server.


Method Two: Use database for authentication (MySQL is selected here), create Apache ftpserver server

1, the front two steps are the same, download and unzip.

2, into the apache-ftpserver-1.0.6\res\conf, to carry out the relevant configuration;

First, select a database (use ftpserver here) to create a database based on the commands in the file apache-ftpserver-1.0.6/res/ftp-db.sql;

Next, add a record to the database: INSERT INTO ftp_user values ("user1", "123456", "./res/home", 1,0,0,0,0,0,0);

Then, create the configuration file: Ftpd-db.xml

Finally, add ftpd-db.xml content, as follows:

<?xml version= "1.0" encoding= "UTF-8"?><!--Licensed to the Apache software Foundation (ASF) under one or more con Tributor 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 are not a use of this file except in compliance with the License. Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 unless required by applicable law or AG Reed to in writing, software distributed under the License are distributed on a "as is" BASIS, without warranties OR Condi tions of any KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --><server xmlns= "Http://mina.apache.org/ftpserver/spring/v1" xmlns:xsi= "http://www.w3.org/2001/   Xmlschema-instance "xmlns:beans=" Http://www.springframework.org/schema/beans "xsi:schemalocation="        Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5           . xsd http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd "Id=" MyServer "><listeners><nio-listener name=" Default "port=" 2121 "><ssl><keystore file=". /res/ftpserver.jks "password=" password "/></ssl></nio-listener></listeners><!--to comment out the file way- -><!--<file-user-manager file= "./res/conf/users.properties"/>--><db-user-manager Encrypt-passwords= "Clear" ><!--data source information, ftpserver MySQL database name, root/root, username and password--><data-source>< Beans:bean class= "Org.apache.commons.dbcp.BasicDataSource" ><beans:property name= "Driverclassname" value= " Com.mysql.jdbc.Driver "/><beans:property name=" url "value=" Jdbc:mysql://localhost/ftpserver "/><beans: Property name= "username" value= "root"/><beans:property name= "password" value= "root"/></beans:bean></data-source><insert-user>insert into Ftp_user (userid, UserPassword, HomeDirectory, Enableflag, Writepermission, Idletime, uploadrate,downloadrate) VALUES (' {userid} ', ' {userpassword} ', ' {homedirectory} ', {Enableflag}, {writepermission}, {idletime},{uploadrate},{downloadrate}) </insert-user> <update-user>update ftp_user setuserpassword= ' {userpassword} ', homedirectory= ' {homedirectory} ', enableflag={ enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={ Downloadrate}where userid= ' {userid} ' </update-user><delete-user>delete from ftp_user WHERE userid = ' { UserID} ' </delete-user><select-user>select userid, UserPassword, Homedirectory,enableflag, Writepermission, Idletime, Uploadrate, Downloadrate,maxloginnumber, Maxloginperip fromftp_user WHERE userid = ' {userid} ' ' </select-user><select-all-users>select userid from Ftp_user ORDER by userid</select-all-users&Gt;<is-admin>select userid from Ftp_user WHERE userid= ' {userid} ' anduserid= ' admin ' </is-admin>< Authenticate>select UserPassword from Ftp_user whereuserid= ' {userid} ' </authenticate></db-user-manager ></server>

3. Guide Jar Package

to increase the jar used for database connections, download 3 jar packages to Directory Apache-ftpserver-1.0.6/common/lib:commons-dbcp-1.2.2.jar, Commons-pool-1.3.jar,

Mysql-connector-java-3.1.13-bin.jar

4, installation and start ftpserver;

Go to cmd command/bin this directory execution (Win7 environment needs to start cmd as Administrator),

Service Install

Ftpd.bat Res/conf/ftpd-db.xml (note: Not the same as the XML loaded on the previous boot)

5. Login Apache Ftpserver

Open the browser, enter: Ftp://hostaddress:port, such as: ftp://10.0.0.132:2121, enter the user and password: User1 123456, log on to the FTP file server.


The configuration is detailed below:

Open the Ftpserver installation directory with the following directories: Bin, Common, res, three.

1, the current to care Res directory, below to look at the directory:

A, conf directory, the directory is mainly stored with the Ftpserver-related configuration files, will be described in detail later.

b, home directory, this directory is mainly used to store files on the FTP server (ftpserver default in this directory), can be modified by the configuration file to the destination, will be described in detail later.

C, log directory, from the directory name can be known as the place to store the log, generally we do not care about the directory.

B, Ftp-db.sql, Ftpserver.jks file,ftp-db.sql file represents a table statement when creating an FTP server with a database connection

2. conf directory:

A, take a look at the Users.properties file, the main user of the file ftpserver User Configuration. Here's a look at the detailed description of each configuration item for the file:

  #密码为1234   tpserver.user.anonymous.userpassword=1234   #主目录 (ftpserver file storage directory)   Ftpserver.user.anonymous.homedirectory=./res/home   #当前用户可用   ftpserver.user.anonymous.enableflag=true   #具有上传权限   ftpserver.user.anonymous.writepermission=true   #最大登陆用户数为20   Ftpserver.user.anonymous.maxloginnumber=20   #同IP登陆用户数为2   ftpserver.user.anonymous.maxloginperip=2   #空闲时间为300秒   ftpserver.user.anonymous.idletime=300   #上传速率限制为48字节每秒   ftpserver.user.anonymous.uploadrate=4800   #下载速率限制为48字节每秒   ftpserver.user.anonymous.downloadrate=4800

I, user name and password settings:

Set user name: ftpserver.user.xxxxxx. userpassword=1234 is used to set the password, indicating that the current password is 1234,xxxxxx as the user name, which is arbitrarily customized.

II. Set the home directory of the account (ftpserver file directory)

Set file home directory:Ftpserver.user.anonymous.homedirectory=./res/home, which represents the home directory in the Res directory where the current home directory is the Ftpserver installation directory.

b, then look at the Ftpd-typical.xml file:

I, add a property under the server root element: (after adding the following properties, cannot be opened in IE)

Open the XML file, locate the server root element, and the default server root element has only one id attribute value of myserver.

#最大用户登录数

max-logins= "

#是否允许用户匿名登录

anon-enabled= "false"

#以下三个属性一般不会进行修改

max-anon-logins= "0"

Max-login-failures= "3"

Login-failure-delay= "30000"

II. Modify the Ftpserver port:

Locate the Nio-listener element, and modify the port property of the element to the ports that need to be modified.

3. About creating Ftpserver using a data connection point that needs to be explained.

In the Ftpd-db.xml section of the Server Properties section must write, otherwise you will not find beans,

Error: The prefix "Beans" for element "Beans:bean" was not bound;

Db-user-manager attribute section (encrypt-passwords= "clear") must write, here the password encryption method is clear, otherwise the login is unsuccessful;

The following red font indicates localhost(the IP address where the database resides ),ftpserver(database name), Root(the user name of the connection database),root(connection database password).









Apache Ftpserver Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.