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. PHP下载远程文件的3种方法以及性能考虑

    今天在做导出Excel的时候,总是要测试导出的Excel文件,频繁的下载和打开,很麻烦 就想着写段代码一气呵成  服务端导出Excel==>下载Excel文件到本地==>并打开的操作. 这 ...

  2. 如何修改SESSION的生存时间

    php中session过期时间设置网上很多人给出了解答:修改php配置文件中的session.gc_maxlifetime.如果想了解更多session回收机制,继续阅读.(本文环境php5.2) 概 ...

  3. error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

    解决编译php扩展xsl时出现 error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution ...

  4. c++通过类名动态创建对象

    转载:http://www.seacha.com/article.php/knowledge/cbase/2013/0615/2154.html 主要思想:在每次创建类的过程中,通过各自类的辅助类(所 ...

  5. Linux虚拟机安装完centos后环境配置

    linux下面安装软件 yum install rpm -ivh 编译安装 三部曲:./configure make make install 卸载 rpm -e 安装方法 1)通过yum安装软件 需 ...

  6. 第二章----python函数

    第一节:调用函数 1.函数是什么? 函数是组织好的,可以重复利用的. 2.为什么要用到函数? 提高应用的模块性,提高重复利用率.指的是:多个文件中可能都要用到该函数,直接拿来调用就行,不用在重复写一个 ...

  7. MongoDB save()方法和insert()方法的区别

    MongoDB save()方法和insert()方法的区别 首先看官方文档怎么说的 Updates an existing document or inserts a new document, d ...

  8. 【转】10 个MySQL数据库备份教程推荐

    10 个MySQL数据库备份教程推荐 MySQL是动态网站开发中最著名的开源数据库系统.如果你在网站中使用了MySQL,那么你应该定期备份你的数据以防止它丢失. 本文将介绍自动或手动备份MySQL数据 ...

  9. K-th Number(主席树)

    K-th Number Time Limit: 20000MS   Memory Limit: 65536K Total Submissions: 59327   Accepted: 20660 Ca ...

  10. 安装mysql报错—解决方法:error while loading shared libraries: libssl.so.6

    for 32bit ln -sf /usr/lib/libssl.so.10 /usr/lib/libssl.so.6ln -sf /usr/lib/libcrypto.so.10 /usr/lib/ ...