linux 下 apache-ftpserver的安装

1. 下载apache-ftpserver-1.1.1.tar.gz

请自行下载

2. 解压apache-ftpserver-1.1.1.tar.gz

tar -xzvf apache-ftpserver-1.1.1.tar.gz

3. 安装目录的res\conf目录中找到users.properties

备份:

cp user.properties user.properties.bak

修改该配置文件:

ftpserver.user.用户名.userpassword=admin // 此处是明文
ftpserver.user.用户名.homedirectory= .. //客户端上传的文件都放在这里。  
ftpserver.user.用户名.enableflag=true
ftpserver.user.用户名.writepermission=true //可写权限
ftpserver.user.用户名.maxloginnumber=3
ftpserver.user.用户名.maxloginperip=3
ftpserver.user.用户名.idletime=0
ftpserver.user.用户名.uploadrate=0
ftpserver.user.用户名.downloadrate=0

4. 配置ftpd-typical.xml

备份:名为ftpd-typical-bak.xml

cp ftpd-typical.xml ftpd-typical-bak.xml

修改ftpd-typical.xml(根据需要进行配置,我直接忽略了)

<server xmlns="http://mina.apache.org/ftpserver/spring/v1"    
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
    xsi:schemaLocation="    
       http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd"    
        id="myServer"        /*设置server的标志符,必须*/    
        max-logins="5"       /*设置同时登陆的最大人数*/    
        anon-enabled="false" /*设置匿名登陆为不允许*/    
        max-anon-logins="0"  /*设置匿名登陆用户为0个*/    
        max-login-failures="3"  /*设置3次失败登陆后,关闭此链接*/    
    >    
    <listeners>    
           <nio-listener name="default" port="2121"><!--设置默认的链接端口为2121,必须-->    
        <ssl>    
                    <keystore file="./res/ftpserver.jks" password="password" /><!--设置密钥存储路径和密钥存储密码,必须-->    
                </ssl>    
            <data-connection idle-timeout="60"><!--设置多少时间后关闭一个闲置的链接,单位是秒-->    
            <active local-port="1886"/><!--设置主动链接配置,端口号“1886”-->    
            <!--设置被动链接配置,端口设置为“1886”,扩展地址为“137.222.18.114”,当需要访问的服务器返回外网地址时使用-->    
            <passive ports="1886" address="0.0.0.0" external-address="137.222.18.114"/>    
            </data-connection>    
        </nio-listener>    
    </listeners>    
    <!--设置用户登陆信息,“./res/conf/users.properties”为文件路径,“encrypt-passwords=‘clear’”设置密码加密方式,默认是“MD5”,设置成“clear”表示不加密,直接输入-->    
    <file-user-manager file="./res/conf/users.properties" encrypt-passwords="clear"/>    
</server>  

5. 关闭防火墙ftpsever端口在外网的访问

禁用所有2121端口的访问

iptables -I INPUT 5 -p tcp -m tcp --dport 2121 -j REJECT

开启来自127.0.0.1的2121端口访问

iptables -I INPUT 5 -s 127.0.0.1/32 -p tcp -m tcp --dport 2121 -j ACCEPT

保存规则

service iptables save

由于本人使用的是centerOS7,故防火墙是有firewalld管理的,如需使用旧版本的iptables,需进行如下设置:

1. 关闭firewalld

systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

systemctl stop firewalld  
systemctl mask firewalld 

2. 安装iptables-services

yum install iptables-services

3. 设置开机启动

systemctl enable iptables

//一些其他命令
systemctl stop iptables  
systemctl start iptables  
systemctl restart iptables  
systemctl reload iptables

4. 保存设置

service iptables save

6. 启动ftpserver

nohup ./bin/ftpd.sh res/conf/ftpd-typical.xml & 

此方式为后台启动FTP服务,服务一直启动不管窗口是否退出。

7. QA

  • ftpserver.user.用户名.homedirectory中的用户名是什么意思?
    用户名此处自定义,用于登录ftp服务器。demo如下:
ftpserver.user.admin.userpassword=admin // 此处是明文
ftpserver.user.admin.homedirectory= /ftp/home //客户端上传的文件都放在这里。  

//此处登录ftp时,使用admin,admin即可。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值