from pyftpdlib.authorizers import DummyAuthorizer

from pyftpdlib.handlers import FTPHandler

from pyftpdlib.servers import FTPServer

import os

def main():

# Instantiate a dummy authorizer for managing 'virtual' users

authorizer = DummyAuthorizer()

# Define a new user having full r/w permissions and a read-only
# anonymous user
authorizer.add_user('admin', '12345', '/root',perm='elradfmwM')
#authorizer.add_anonymous(os.getcwd()) # Instantiate FTP handler class
handler = FTPHandler
handler.authorizer = authorizer # Define a customized banner (string returned when client connects)
handler.banner = "Simple FTPServer." # Specify a masquerade address and the range of ports to use for
# passive connections. Decomment in case you're behind a NAT.
#handler.masquerade_address = '151.25.42.11'
#handler.passive_ports = range(60000, 65535) # Instantiate FTP server class and listen on 0.0.0.0:2121
address = ('192.168.3.177', 21)
server = FTPServer(address, handler) # set a limit for connections
server.max_cons = 256
server.max_cons_per_ip = 5
# start ftp server
server.serve_forever()

if name == 'main':

main()

关于脚本的一些说明:

建立一个authorizer = DummyAuthorizer() 对象的实例

利用.add_user方法添加一个用户 authorizer.add_user('admin', '12345', '/root',perm='elradfmwM')

关于建立用户的参数的说明:

admin 用户名

'12345' 密码

/root 用户的根目录

perm='elradfmwM' 设置用户的权限

关于perm='elradfmwM' 参数介绍:

Read permissions:

- "e" = change directory (CWD command)

- "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE, MDTM commands)

- "r" = retrieve file from the server (RETR command)

Write permissions:
- "a" = append data to an existing file (APPE command)
- "d" = delete file or directory (DELE, RMD commands)
- "f" = rename file or directory (RNFR, RNTO commands)
- "m" = create directory (MKD command)
- "w" = store a file to the server (STOR, STOU commands)
- "M" = change file mode (SITE CHMOD command)

Linux下pyftplib简单的脚本的更多相关文章

  1. [转]Linux下的lds链接脚本详解

    转载自:http://linux.chinaunix.net/techdoc/beginner/2009/08/12/1129972.shtml     一. 概论 每一个链接过程都由链接脚本(lin ...

  2. Linux下的lds链接脚本简介

    转载:http://hubingforever.blog.163.com/blog/static/171040579201192472552886/   一. 概论 每一个链接过程都由链接脚本(lin ...

  3. Linux下一个简单的日志系统的设计及其C代码实现

    1.概述 在大型软件系统中,为了监测软件运行状况及排查软件故障,一般都会要求软件程序在运行的过程中产生日志文件.在日志文件中存放程序流程中的一些重要信息, 包括:变量名称及其值.消息结构定义.函数返回 ...

  4. Linux下的lds链接脚本详解【转】

    转自:http://www.cnblogs.com/li-hao/p/4107964.html 转载自:http://linux.chinaunix.net/techdoc/beginner/2009 ...

  5. Linux下的lds链接脚本详解

    1. 概论2. 基本概念3. 脚本格式4. 简单例子5. 简单脚本命令6. 对符号的赋值7. SECTIONS命令8. MEMORY命令9. PHDRS命令10. VERSION命令11. 脚本内的表 ...

  6. Linux下的lds链接脚本简介(二)

    七. SECTIONS命令 SECTIONS命令告诉ld如何把输入文件的sections映射到输出文件的各个section: 如何将输入section合为输出section; 如何把输出section ...

  7. 在Linux下如何用Shell脚本读写XML?现有一个config.xml(转)

    在Linux下如何用Shell脚本读写XML?现有一个config.xml <?xml version="1.0" encoding="UTF-8"?&g ...

  8. Android: 通过Runtime.getRuntime().exec调用底层Linux下的程序或脚本

    Android Runtime使得直接调用底层Linux下的可执行程序或脚本成为可能 比如Linux下写个测试工具,直接编译后apk中通过Runtime来调用 或者写个脚本,apk中直接调用,省去中间 ...

  9. linux下的日志压缩脚本

    linux下的日志压缩脚本: #!/bin/bash #第一步:先定义项目列表如下: projects="project-a project-b project-c project-d&qu ...

随机推荐

  1. 51nod-完美字符串(贪心)

    约翰认为字符串的完美度等于它里面所有字母的完美度之和.每个字母的完美度可以由你来分配,不同字母的完美度不同,分别对应一个1-26之间的整数. 约翰不在乎字母大小写.(也就是说字母F和f)的完美度相同. ...

  2. 批量删除.svn目录

    find . -type d -name ".svn"|xargs rm -rf find . -type d -iname ".svn" -exec rm - ...

  3. Java基础学习总结(37)——Java23中设计模式(Design Patterns)详解

    设计模式(Design Patterns) --可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...

  4. CF449 C. Jzzhu and Apples

    /* http://codeforces.com/problemset/problem/449/C cf 449 C. Jzzhu and Apples 数论+素数+贪心 */ #include &l ...

  5. 如何利用eclipse实现批量修改文件的编码方式

        在eclipse+Eclipse环境下,打开一个jsp文件,经常发现汉字无法显示,右键点击查看这个文件属性,发现文件的字符编码属性为ISO-8859-1.    目前的解决方法有:1. 手工把 ...

  6. CAD教程----圆的优化命令viewres

    CAD软件为了节省内存加快打开图纸的速度,会在显示圆形的时候,用很粗燥的直线表示园,这时我们可以不节省内存,使用viewres将圆形完整的显示出来. 这个值设置的越大,圆越圆(好绕口!)

  7. [SharePoint2010开发入门经典]12、SPS2010安全管理

    本章概要: 1.SPS中的用户授权 2.理解服务器场解决方案和沙箱解决方案的不同 3.理解表单验证和声明验证

  8. 动态为TextView控件设置drawableLeft图标,并设置间距

    效果图: 重要属性: textView.setCompoundDrawablePadding(4);//设置图片和text之间的间距 textView.setPadding(-5, 0, 0, 0); ...

  9. hdu1181(变形课)

    点击打开链接 Problem Description 呃......变形课上Harry碰到了一点小麻烦,由于他并不像Hermione那样可以记住全部的咒语而任意的将一个棒球变成刺猬什么的,可是他发现了 ...

  10. 在外星人电脑上安装windows10和ubuntu16.04双系统小记

    最近刚刚入手了一台Alienware Aurora R6,买这货的主要目的是为了研究Deep Learning.之所以没有买组装机的原因,主要是担心组装机的不稳定,而实验经费中的设备费也还相对充足,于 ...