免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2312 | 回复: 1
打印 上一主题 下一主题

:wink: 使用pyftpdlib 时发生错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-11-16 09:22 |只看该作者 |倒序浏览
环境  python 2.7   pyftpdlib 0.7.0  ubuntu 12.04
执行python ftps-server.py

用 python 2.7 带的ftplib就可以
In [1]: from ftplib import FTP_TLS

In [2]: ftps = FTP_TLS('127.0.0.1','user','bbbb')

error_perm: 530 Authentication failed.

使用lftp 登录  ftps时提示错误
lftp ftps://fa:aa@127.0.0.1:21

lftp fa@127.0.0.1:~> ls
ls: Fatal error: gnutls_handshake: A TLS packet with unexpected length was received.
大家帮忙看看什么原因了?




















ftps_server.py代码如下:
  1. from pyftpdlib import ftpserver
  2. from pyftpdlib.contrib.handlers import TLS_FTPHandler,FTPHandler
  3. import md5



  4. class MyHandler(TLS_FTPHandler):

  5.     def on_login(self, username):
  6.         # do something when user login
  7.         print 'username:%s' % username
  8.        
  9.         def on_login_failed(self, username, password):
  10.                 print 'afasfd-----------------------------------'
  11.                 print 'password:%s' % password

  12.     def on_logout(self, username):
  13.         # do something when user logs out
  14.         pass
  15.         
  16.     def on_file_sent(self, file):
  17.         # do something when a file has been sent
  18.         pass

  19.     def on_file_received(self, file):
  20.         # do something when a file has been received
  21.         pass
  22.             
  23.     def on_incomplete_file_sent(self, file):
  24.         # do something when a file is partially sent
  25.         pass

  26.     def on_incomplete_file_received(self, file):
  27.         # remove partially uploaded files
  28.         pass
  29.                
  30.                


  31. authorizer = ftpserver.DummyAuthorizer()
  32. authorizer.add_user('user', '12345', '.', perm='elradfmw')


  33. #authorizer.add_anonymous('.')
  34. handler = MyHandler
  35. handler.certfile = 'keycert.pem'

  36. handler.authorizer = authorizer
  37.     # requires SSL for both control and data channel
  38.     #handler.tls_control_required = True
  39.     #handler.tls_data_required = True
  40. ftpd1 = ftpserver.FTPServer(('127.0.0.1', 21), handler)

  41. ftpd1.serve_forever()
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-11-16 21:23 |只看该作者
搞定。
lftp ftp://fa:aa@127.0.0.1:21



不知到为什么会这样?
那位高人能帮助解释一下啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP