<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
如下圖:
<?xml version="1.0" encoding="UTF-8"?> <!-- 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. --> <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 https://mina.apache.org/ftpserver-project/ftpserver-1.0.xsd " id="myServer"> <listeners> <nio-listener name="default" port="21"> <ssl> <keystore file="./res/ftpserver.jks" password="password" /> </ssl> </nio-listener> </listeners> <file-user-manager file="./res/conf/users.properties" /> </server>
目前資料庫管理使用者時採用的明文儲存,salted和md5的方式沒有測試成功,如有測試成功的朋友請指導一下。
<?xml version="1.0" encoding="UTF-8"?> <!-- 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. --> <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="21"> <ssl> <keystore file="./res/ftpserver.jks" password="password" /> </ssl> </nio-listener> </listeners> <db-user-manager encrypt-passwords="clear"> <data-source> <beans:bean class="org.apache.commons.dbcp2.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="123456" /> </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 SET userpassword='{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 FROM FTP_USER WHERE userid = '{userid}' </select-user> <select-all-users> SELECT userid FROM FTP_USER ORDER BY userid </select-all-users> <is-admin>SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin' </is-admin> <authenticate>SELECT userpassword from FTP_USER WHERE userid='{userid}' </authenticate> </db-user-manager> </server>
注意:org.apache.commons.dbcp2.BasicDataSource,看最新的commons.dbcp名稱空間和1.x版本有區別
<?xml version="1.0" encoding="UTF-8"?> <!-- 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. --> <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="21"> <ssl> <keystore file="./res/ftpserver.jks" password="password" /> </ssl> </nio-listener> </listeners> <db-user-manager encrypt-passwords="clear"> <data-source> <beans:bean class="org.apache.commons.dbcp2.BasicDataSource"> <beans:property name="driverClassName" value="org.sqlite.JDBC" /> <beans:property name="url" value="jdbc:sqlite:ftp.db" /> </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 SET userpassword='{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 FROM FTP_USER WHERE userid = '{userid}' </select-user> <select-all-users> SELECT userid FROM FTP_USER ORDER BY userid </select-all-users> <is-admin>SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin' </is-admin> <authenticate>SELECT userpassword from FTP_USER WHERE userid='{userid}' </authenticate> </db-user-manager> </server>
注意:commons的jar包還保留著,多了個操作sqlitejdbc的jar包,下載地址:GitHub - xerial/sqlite-jdbc: SQLite JDBC Driver
需下載tomcat包,目前測試的這個版本可行tomcat-7 v7.0.109 (apache.org)
放入apache ftpserver bin目錄裡替換原有的ftpd.exe
這樣安裝為服務的時候就可以正常啟動了
自己搞了個python指令碼,採用了sqlalchemy來運算元據庫
from sqlalchemy import create_engine from sqlalchemy import MetaData,Table,Column,Boolean,Integer,String import os engine=create_engine('sqlite:///ftp.db') conn=engine.connect() metadata=MetaData() ftpusers=Table('FTP_USER',metadata, Column('userid',String(64),primary_key=True), Column('userpassword',String(64),nullable=False), Column('homedirectory',String(128),nullable=False), Column('enableflag',Boolean(),default=True), Column('writepermission',Boolean(),default=True), Column('idletime',Integer(),default=0), Column('uploadrate',Integer(),default=0), Column('downloadrate',Integer(),default=0), Column('maxloginnumber',Integer(),default=0), Column('maxloginperip',Integer(),default=0) ) metadata.create_all(engine) def addgeneraluser(): deluser = ftpusers.delete().where(ftpusers.c.userid=="nic") rs = conn.execute(deluser) dirname="./files/alluser" if not os.path.exists(dirname): os.mkdir(dirname) ins=ftpusers.insert().values( userid="nic", userpassword="123321", homedirectory=dirname, writepermission=0, maxloginnumber=1 ) result=conn.execute(ins) def addadmin(): deladmin = ftpusers.delete().where(ftpusers.c.userid=="admin") rs = conn.execute(deladmin) ins=ftpusers.insert().values( userid="admin", userpassword="123456", homedirectory="./files", writepermission=1 ) result=conn.execute(ins) def getusers(): sel=ftpusers.select() rs=conn.execute(sel) print(rs.fetchall()) addgeneraluser() getusers()
可以方便的增加使用者了,generaluser唯讀許可權只能同時登入一個,admin許可權可讀寫,不限制。
到此這篇關於利用apache ftpserver搭建ftp伺服器的方法步驟的文章就介紹到這了,更多相關apache ftpserver搭建ftp內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45