shell-跳板机便捷增加用户及设置密码
我的需求:
因网络限制,某些客户机ssh到服务器都得使用跳板机进行转一下,每次帮开帐户,不麻烦不难,但总觉得还可以再优。
不多说,直接放shell。很简单
#!/bin/bash
#test add user and set passwd
username=$1
adduser_log=/data1/useradd.log
password=`echo $username |md5sum|cut -c1-8`
if [ -n "$username" ]
then
#检查用户是否存在
if id -u $username >/dev/null 2>&1; then
echo "user exists" else
echo "user does not exist,start set up"
useradd $username
echo $password | sudo passwd $username --stdin &>/dev/null
echo "增加成功:"$username/$password
echo "-----------增加成功:"$username/$password>>$adduser_log fi
else
echo "script properties is cannot null"
fi
结果:

shell-跳板机便捷增加用户及设置密码的更多相关文章
- Shell跳板机sshstack
笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 源码地址: https://github.com/sshstack/sshstack 为什么要写shell跳板机? ...
- shell开源跳板机sshstack
笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 源码地址: https://github.com/sshstack/sshstack 为什么要写shell跳板机? ...
- linux跳板机开发之trap信号机应用
场景1:公司新招聘了一个配置管理员,他的工作是负责将公司开发人员写的新代码依次分发到办公室测试环境.IDC测试环境和正式线上环境.因此公司需要开发一个程序,当配置管理员登录服务器,只能进入分发的管理界 ...
- Linux系统——JumpServer跳板机的搭建和部署
公网源部署jumpserver跳板机 建立阿里云公网源yum仓库(服务端)[root@localhost ~]# lsanaconda-ks.cfg install.log.syslog jumpse ...
- 运维常用shell脚本一(系统指标巡检、自动创建用户、跳板机)
一.系统指标巡检脚本 #!/bin/bash menu(){ cat <<EOF +---------------------------------------------+ | 日常巡 ...
- Shell实现跳板机,为什么用跳板机
整理自:http://blog.chinaunix.net/uid-22101889-id-3167454.html 注意:请谨慎使用,到现在为止,使用了,我还没找到改回去的方法. 1. 问题 ...
- shell脚本之nginx启动脚本、统计日志字段、for循环实战、跳板机
1.NGINX启动脚本 #!/bin/bash # chkconfig: 235 32 62 # description: nginx [ -f /etc/init.d/functions ] &am ...
- shell脚本中添加用户并设置密码
有时候在初始化shell脚本中希望能顺便创建用户并指定密码,使用useradd命令可以达到该效果: useradd -m -p encryptedPassword username 参数说明: -m ...
- jumpserver跳板机搭建,适合centos6和centos7的使用
第17章 jumpserver的搭建 17.1 jumpserver的介绍 jumpserver是全球首款开源的堡垒机,使用的是GNU,GPL的开源协议. jumpserver是用python和g ...
随机推荐
- [BZOJ3080]Minimum Variance Spanning Tree/[BZOJ3754]Tree之最小方差树
[BZOJ3080]Minimum Variance Spanning Tree/[BZOJ3754]Tree之最小方差树 题目大意: 给定一个\(n(n\le50)\)个点,\(m(m\le1000 ...
- C++学习笔记38:事件机制
事件基本概念 操作系统或应用程序内部发生某件事,程序的某个组件需要响应该事件,并进行特定处理 面向对象架构中,事件响应函数最可能为成员函数 问题:指向类成员函数的指针不能转换为哑型指针void *,也 ...
- EasyUI学习总结(五)——EasyUI组件使用
一.EasyUI组件的简单介绍 easyUI提供了很多组件让我们使用,如下图所示:
- Hook Directx + CEGUI VC++
void CtestwmDlg::OnBnClickedButton1() { CStringA lpszFile; m_file.GetWindowText(lpszFile); if (lpszF ...
- Date与Quartz的cron之间的相互转换
1.概述 最近在写一个Quartz相关的模块,需要实现Date与Quartz的cron之间的相互转换,在网上查了一下竟然没有找到,但是找到一份这样的博客:http://hw1287789687.ite ...
- WIN10平板 如何关闭自动更新
运行,services.msc打开组策略 找到Windows Update,设置启动类型为禁用即可
- vmware虚拟机环境下配置centos为静态IP的步骤
一.修改centos配置文件 配置文件位于/etc/sysconfig/network-scripts/ifcfg-eth0 修改的内容为: ONBOOT=yes BOOTPROTO=static I ...
- flex学习, 尝试布局一个计算器
<!DOCTYPE html> <html> <head> <title>flex</title> </head> <st ...
- getting-started-with-mqtt
来自:https://dzone.com/refcardz/getting-started-with-mqtt SECTION 1 Why MQTT? The Internet of Things ( ...
- xcode 报错 malloc: *** error for object 0x6c3c5a4: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug------d
大家有时候会遇到这个错误 malloc: *** error for object 0x******: incorrect checksum for freed object - object was ...