1 Star 0 Fork 23

sunbin/Auto_Install_console

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
account.py 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
awakenjoys 提交于 2014-03-04 18:33 . test
# -*- coding:utf8 -*-
from core import *
#----------------------------------------------------------------------------------------
#新加一个Linux账户
def add_account(server, port, username, password, account, passwd):
cmd_user = "useradd %s" % account
cmd_pass = "echo \"%s:%s\" | /usr/sbin/chpasswd" % (account, passwd)
check = "cat /etc/passwd | grep %s" % account
cmds = []
cmds.append(cmd_user)
cmds.append(cmd_pass)
cmds.append(check)
ret = execute(server, port, username, password, cmds)
return ret
#----------------------------------------------------------------------------------------
#删除Linux账户
def del_account(server, port, username, password, account):
cmd = "userdel -f %s" % account
cmds = []
cmds.append(cmd)
ret = execute(server, port, username, password, cmds)
return ret
#----------------------------------------------------------------------------------------
#修改密码
def modify_pass(server, port, username, password, account, newpasswd):
cmd_newpass = "echo \"%s:%s\" | /usr/sbin/chpasswd" % (account, newpasswd)
cmds = []
cmds.append(cmd_newpass)
ret = execute(server, port, username, password, cmds)
return ret
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/sunbinlc/Auto_Install_console.git
git@gitee.com:sunbinlc/Auto_Install_console.git
sunbinlc
Auto_Install_console
Auto_Install_console
master

搜索帮助