首页 > 代码库 > Centos小脚本(sftp)
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()
Centos小脚本(sftp)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。