博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
定时修改用户密码
阅读量:4634 次
发布时间:2019-06-09

本文共 1194 字,大约阅读时间需要 3 分钟。

Auth: Jin

Date: 20140403

Content: 

1 #!/bin/bash - 2 ### auth: Jin 3 ### date: 20140311 4 ### Desc: 创建没有写入权限的普通用户,创建修改随机密码脚本changepassword.sh并将脚本加入crontab  5 ### Usage: ./tmp.sh  6  7 #user and permit 8 groupadd viewer && useradd viewer -g viewer && cat /proc/sys/kernel/random/uuid|passwd --stdin viewer && printf "umask 222\n" >> ~viewer/.bashrc && chmod 500 /home/viewer 9 #ssh key10 mkdir ~viewer/.ssh/ && cp ~root/.ssh/authorized_keys ~viewer/.ssh/11 12 13 #change password shell14 mkdir -p  /home/gbin && touch /home/gbin/changepassword.sh && chmod 750 /home/gbin/changepassword.sh15 #content16 shellcontent="#/bin/bash17 ### auth: Jin18 ### date: 2014031119 20 secret=\`cat /proc/sys/kernel/random/uuid | cut -d'-' -f1,3,5\`21 22 passwd <
/home/gbin/changepassword.sh << EOF34 $shellcontent35 EOF36 37 #注意几个转意的地方38 #add crontal39 cat >> /var/spool/cron/root << EOF40 0 2 * * * /home/gbin/changepassword.sh >> /home/gbin/changepassword.log 2>&141 EOF42 43 #test change password shell44 /home/gbin/changepassword.sh >> /home/gbin/changepassword.log 2>&1 && cat /home/gbin/changepassword.log45 46 trap "rm -f ./tmp.sh;exit" 0

转载于:https://www.cnblogs.com/diege/p/3642907.html

你可能感兴趣的文章
Socket、Http、TCP/IP、UDP的联系与区别
查看>>
包装函数
查看>>
原理系列:Spark1.x 生态圈一览
查看>>
django模板系统(下)
查看>>
HDU 1711 Number Sequence(KMP模板)
查看>>
如何查看Ubuntu版本
查看>>
本杰明 富兰克林 道德13准则
查看>>
JAVA 操作系统已经来到第五个版本了 现陆续放出三个版本 这是第二个版本
查看>>
LightOJ 1370 Bi-shoe and Phi-shoe(欧拉函数)
查看>>
C#指南,重温基础,展望远方!(4)表达式
查看>>
统计元音
查看>>
悼念512汶川大地震遇难同胞——一定要记住我爱你
查看>>
荷兰国旗问题
查看>>
Day-5: Python高级特性
查看>>
BZOJ 离线网站
查看>>
IIS服务器SSL证书安装
查看>>
void和void *
查看>>
继续教育学习脚本
查看>>
改装摩托车
查看>>
Html.Partial和Html. RenderPartial用法
查看>>