sftp用户创建,改变属组,家目录

#!/bin/python
import os,sys
class sftp_user(object):
def __init__(self,user,passwd):
self.user = user
self.passwd = passwd
# 改变用户的属组
def user_mod(self):
for i in self.user:
data = os.popen("usermod -g sftp %s"%i).read()
print(data)
#增加账户及设置密码
def user_add(self):
connect = 0
for i in self.user:
output1 = os.popen("useradd %s"%i).read()
print(output1)
#output = os.popen("echo '%s:%s'|chpasswd"%(i,j)).read()
output2 = os.popen("echo '%s' |passwd --stdin %s"%(self.passwd[connect],i)).read()
connect += 1
print(output2) #删除用户及家目录
def user_del(self):
for i in self.user:
output = os.popen("userdel %s"%i).read()
os.popen("rm -rf /home/%s"%i)
print(output)
def fill_create(self):
pass
#改变用户家目录及改变权限
def fill_chown(self):
for i in self.user:
os.popen("usermod -d /mnt/ftp/chinaflux/tongliangshuju-2-jieguo/%s %s"%(i,i))
os.popen("chown %s:sftp -R /mnt/ftp/chinaflux/tongliangshuju-2-jieguo/%s"%(i,i))
os.popen("chmod 755 /mnt/ftp/chinaflux/tongliangshuju-2-jieguo/%s"%i) user = ["arou","ailaoshan","damao""daxinganling","danzhou"]
passwd = ["arou","ailaoshan","damao""daxinganling","danzhou"]
abc = sftp_user(user,passwd)
abc.user_add()
#abc.user_del()

Centos小脚本(sftp)的更多相关文章

  1. centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课

    centos  shell脚本编程2 if 判断  case判断   shell脚本中的循环  for   while   shell中的函数  break  continue  test 命令   ...

  2. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  3. centos 查看脚本

    centos 查看脚本 #!/bin/bash date >>info.txt echo "本机centos版本为" >>info.txt cat /etc ...

  4. 第一个Mac shell 小脚本

    大多数程序员都喜欢偷懒的,我也不例外.相信好多Android开发的coder 在网络http请求方面,会浪费很多时间在接口调试这里..有时候,自己写了一个小测试,行还好,不行的话,还要跟写后台的哥们一 ...

  5. 写了一个常规性生成merge 的小脚本

    现在使用数据库来写存储过程,动不动参数就会用到xml ,当然罗,优势也很明显,参数相对固定,而且灵活,如果要修改或者什么的,中间接口层也不需要做变化,只需要修改封装的存储过程以及程序传参就ok了. 随 ...

  6. 周末娱乐一下--------恶搞windows小脚本

    下面这是个循环DOS命令,使用了C中的goto语句 echo命令式输出命令 set命令是设置命令 var是变量,初始为0 :continue是一个用于goto的标示. %var%输出变量名,%var% ...

  7. 用Python实现一个爬取XX大学电费通知的小脚本

    内容简要 1分析网站 2简单爬取 3进阶自定义爬取 4保存进数据库 学校基础设施太差,宿舍电量过低提醒虽然贴在楼下,但是作为低头一族,经常忘记看提醒导致宿舍酣战时突然黑屏,为了避免这种尴尬的场景以及强 ...

  8. 分享一个刷网页PV的python小脚本

    下面分享一个小脚本,用来刷网页PV. [root@huanqiu ~]# cat www.py #!/usr/bin/python# coding: UTF-8import webbrowser as ...

  9. 自动FTP的小脚本

    自动FTP的小脚本 使用以下脚本,可以实现自动FTP,将你需要的文件传送到需要的地方,或者将需要的文件从某个地方抓取下来. cd /PATH_YOU_WANT_TO_UPLOAD(DOWNLOAD) ...

随机推荐

  1. 关于WPF界面框架MahApps.Metro的一个BUG

    碰到了这个问题,记录一下,以便以后查阅: 在一个WPF项目中使用MahApps.Metro界面框架,其中有一个功能是嵌入一个带句柄的标记. 首先WPF是出了窗体和WebBrowser带有句柄外,其他控 ...

  2. CentOS环境下yum安装LAMP

    第一步:更新系统内核 yum -y update 如果执行失败报错,可以执行修复命令:rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY* 第二步: 安装Apahce.M ...

  3. constructors and destructors

    A constructor is a method that gets called immediately when an object is allocated (on the stack or ...

  4. jxta 2.8x启动了

    http://chaupal.github.io/ ———————————————————————————————————————————————————————————————————— 至少两个月 ...

  5. Spring MVC资源绑定视图解析器

    ResourceBundleViewResolver使用属性文件中定义的视图bean来解析视图名称. 以下示例显示如何使用Spring Web MVC框架中的ResourceBundleViewRes ...

  6. Eclipse 运行程序

    运行 Java 程序 我们可以在 Package Explorer 视图 可以在 Package Explorer 视图中快速运行 Java 程序. Package Explorer 视图: 鼠标右击 ...

  7. 关闭数据库时SHUTDOWN: waiting for active calls to complete.处理

    有时候在关闭数据库时,发出shutdown immediate;命令后一直未关闭.查看ALERT日志.在等待一段时间后日志中有提示: SHUTDOWN: waiting for active call ...

  8. Python Theano ValueError: y_i value out of bounds

    参考 https://groups.google.com/forum/#!topic/theano-users/tY3fNAPYd9k 这个问题是由于outs的数量没有设置对. 里面写到 “excep ...

  9. SlidingMenu官方实例分析4——AttachExample

    AttachExample这个类没有继承BaseActivity,而是FragmentActivity,写到这好像感悟到了 为什么官方现在都推荐使用Fragment而不是Activity,因为Frag ...

  10. 进程 vs. 线程

    我们介绍了多进程和多线程,这是实现多任务最常用的两种方式.现在,我们来讨论一下这两种方式的优缺点. 首先,要实现多任务,通常我们会设计Master-Worker模式,Master负责分配任务,Work ...