- 论坛徽章:
- 0
|
环境 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代码如下:- from pyftpdlib import ftpserver
- from pyftpdlib.contrib.handlers import TLS_FTPHandler,FTPHandler
- import md5
- class MyHandler(TLS_FTPHandler):
- def on_login(self, username):
- # do something when user login
- print 'username:%s' % username
-
- def on_login_failed(self, username, password):
- print 'afasfd-----------------------------------'
- print 'password:%s' % password
- def on_logout(self, username):
- # do something when user logs out
- pass
-
- def on_file_sent(self, file):
- # do something when a file has been sent
- pass
- def on_file_received(self, file):
- # do something when a file has been received
- pass
-
- def on_incomplete_file_sent(self, file):
- # do something when a file is partially sent
- pass
- def on_incomplete_file_received(self, file):
- # remove partially uploaded files
- pass
-
-
- authorizer = ftpserver.DummyAuthorizer()
- authorizer.add_user('user', '12345', '.', perm='elradfmw')
- #authorizer.add_anonymous('.')
- handler = MyHandler
- handler.certfile = 'keycert.pem'
- handler.authorizer = authorizer
- # requires SSL for both control and data channel
- #handler.tls_control_required = True
- #handler.tls_data_required = True
- ftpd1 = ftpserver.FTPServer(('127.0.0.1', 21), handler)
- ftpd1.serve_forever()
复制代码 |
|