python FTP服务器实现(Python3)
2018-12-25 08:24:33来源:博客园 阅读 ()
创建一个ftp.py文件(Linux环境),插入以下代码:
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
# 实例化DummyAuthorizer来创建ftp用户
authorizer = DummyAuthorizer()
# 参数:用户名,密码,目录,权限
authorizer.add_user('test', '12345', '/root/ftp', perm='elradfmwMT')
authorizer.add_user('tese1', '12345', '/root/ftp', perm='elradfmwMT')
# 匿名登录
# authorizer.add_anonymous('/home/nobody')
handler = FTPHandler
handler.authorizer = authorizer
# 参数:IP,端口,handler
server = FTPServer(('172.31.8.88', 21), handler)
server.serve_forever()
###### 文件保存
:wq 保存文件
###### 运行:
root@k8s-node1 ~]# nohup python3 ftp.py &
[1] 1737
[root@k8s-node1 ~]# nohup: 忽略输入并把输出追加到"nohup.out"
[root@k8s-node1 ~]# root@k8s-node1 ~]# tail -f nohup.out
[I 2018-11-30 12:52:03] 172.31.8.3:52635-[test] USER 'test' logged in.
[I 2018-11-30 12:57:03] 172.31.8.3:52635-[test] Control connection timed out.
[I 2018-11-30 12:57:03] 172.31.8.3:52635-[test] FTP session closed (disconnect).
[I 2018-12-20 09:36:26] >>> starting FTP server on 172.31.8.88:21, pid=1737 <<<
[I 2018-12-20 09:36:26] concurrency model: async
[I 2018-12-20 09:36:26] masquerade (NAT) address: None
[I 2018-12-20 09:36:26] passive ports: None
[I 2018-12-20 09:36:49] 172.31.8.3:52150-[] FTP session opened (connect)
[I 2018-12-20 09:36:52] 172.31.8.3:52150-[] USER 'anonymous' failed login.
[I 2018-12-20 09:36:52] 172.31.8.3:52150-[] FTP session closed (disconnect).
[I 2018-12-20 09:37:09] 172.31.8.3:52156-[] FTP session opened (connect)
[I 2018-12-20 09:37:12] 172.31.8.3:52156-[] USER 'test' failed login.
[I 2018-12-20 09:37:12] 172.31.8.3:52156-[] FTP session closed (disconnect).
[I 2018-12-20 09:37:16] 172.31.8.3:52159-[] FTP session opened (connect)
[I 2018-12-20 09:37:16] 172.31.8.3:52159-[test] USER 'test' logged in.
[I 2018-12-20 09:37:16] 172.31.8.3:52159-[test] FTP session closed (disconnect).
[I 2018-12-20 09:37:16] 172.31.8.3:52160-[] FTP session opened (connect)
[I 2018-12-20 09:37:16] 172.31.8.3:52160-[test] USER 'test' logged in.
[I 2018-12-20 09:40:13] 172.31.8.3:52160-[test] FTP session closed (disconnect).
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- python3基础之“术语表(2)” 2019-08-13
- python3 之 字符串编码小结(Unicode、utf-8、gbk、gb2312等 2019-08-13
- Python3安装impala 2019-08-13
- 小白如何入门 Python 爬虫? 2019-08-13
- python_字符串方法 2019-08-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash