• Centos小脚本(sftp)


    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()
  • 相关阅读:
    两条斜线
    Cantor表
    城市网络
    一起来数二叉树吧
    牛客网音乐研究(枚举)
    删括号
    合并回文子串
    寻找道路
    EXTJS 4.0.2 XML数据
    extjs4.0.2a gridpanel看不到横向滚动条的一种原因
  • 原文地址:https://www.cnblogs.com/chimeiwangliang/p/7096756.html
Copyright © 2020-2023  润新知