Busybox shell脚本修改密码
/******************************************************************************
* Busybox shell脚本修改密码
* 说明:
* 需要在在Busybox文件系统中修改密码,但是passwd命令需要交互才能修改密码,
* 原来Busybox提供了chpasswd命令,在shell中直接用passwd也是可行的。
*
* 2017-3-9 深圳 南山平山村 曾剑锋
*****************************************************************************/ 一、参考文档:
. how to change password with shell script in busybox 1.4.
http://www.avrfreaks.net/forum/how-change-password-shell-script-busybox-142
. How do you change a user password in a script with busybox and openssl?
http://stackoverflow.com/questions/2059069/how-do-you-change-a-user-password-in-a-script-with-busybox-and-openssl
. How to set a new password from bash?
http://unix.stackexchange.com/questions/26738/how-to-set-a-new-password-from-bash 二、passwd帮助:
[zengjf@root ~]# passwd -h
passwd: invalid option -- 'h'
BusyBox v1.25.0 (-- :: CST) multi-call binary. Usage: passwd [OPTIONS] [USER] Change USER's password (default: current user) -a ALG Encryption method
-d Set password to ''
-l Lock (disable) account
-u Unlock (enable) account
[zengjf@root ~]# 三、解决办法:
. 方法1: compile your own busybox configuration with chpasswd command。
. 方法2:
. 编写一个脚本如下:
#!/bin/sh
passwd << EOF
<new password>
<new password>
EOF
. 输出效果如下
[zengjf@root ~]# ./chpasswd
Changing password for root
New password:
Bad password: too weak
Retype password:
passwd: password for root changed by root
[zengjf@root ~]#
Busybox shell脚本修改密码的更多相关文章
- Linux 通过 shell 脚本修改密码
交互方式修改密码 1. ssh 远程到主机: 2. 切换到root账号: [一般都是切换到root进行密码修改,如果普通用户修改自己的密码,要输入原密码,然后新密码要满足复杂度才OK]: 3. pas ...
- Mac下通过shell脚本修改properties文件
通过shell脚本替换属性文件中的某行记录 假设有如下属性文件 demo.properties user.name=test user.password=123456 ................ ...
- shell脚本修改文本中匹配行之前的行的方法
原创文件,欢迎阅读,禁止转载. 例子中是把 finish 前一行的 "yes" 改成 "YES"有一个方法就是利用sed+awk一起来完成. zjk@zjk:~ ...
- salt 执行shell 脚本 修改名字
#!/bin/bash #命令 匹配主机 执行模块 脚本路径,必须放在salt目录下 源主机名 修改的主机名 #salt tt_LD_LM_LC_1 cmd.script salt://init/re ...
- Shell 脚本修改 Mac IP地址
本篇文章由:http://xinpure.com/shell-script-to-modify-the-mac-ip-address/ 麻烦事 最近在笔记本 WIFI 网络上遇到一个麻烦事, 在公司需 ...
- shell脚本明文密码隐藏且加密
将密码放到文件中去,比如/root/.pass.txtpassword=`</root/.pass.txt`还怕密码泄露的话,就把pass.txt权限设置下. chattr +i /root/. ...
- 〖Linux〗Shell脚本修改输出文字颜色
Shell函数: echocolor(){ color=${} && shift case ${color} in black) echo -e "\e[0;30m${@}\ ...
- shell脚本修改文件
https://blog.csdn.net/qq_37674858/article/details/80066264 2.2 使用sed命令对文件中的字符替换 例如:将aaaa字符串修改为bbbb [ ...
- linux通过shell脚本修改文件内容
sed -i 's/abc/xxx/g' file abc修改前的字符串xxx是修改后的字符串file是要被修改的文件
随机推荐
- QuickSort again
I wrote a blog about Quick Sort before. Let's talk more about it. If you don't think that the implem ...
- LeetCode:二叉树的层次遍历||【107】
LeetCode:二叉树的层次遍历||[107] 题目描述 给定一个二叉树,返回其节点值自底向上的层次遍历. (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历) 例如:给定二叉树 [3,9,2 ...
- freeMarker入门示例
1.创建Web项目freeMarkerDemo. 2.添加jar包---freemarker-2.3.9.jar. 3.在WebContent目录下新建templates文件夹,用于放置模板文件ftl ...
- $《第一行代码:Android》读书笔记——第9章 服务
(一)Service简介 服务适合执行那种不需要和用户交互而且还要长期运行的任务.所有的服务代码都是默认运行在主线程中,需要在服务内部手动添加子线程,在子线程中执行耗时任务. (二)线程 1.线程 ...
- ANSI C和POSIX
简单的说 ANSI C:标准C API(对应fopen) POSIX:方便在Linux下运行的C API(对应open)
- Android : 反射机制获取或设置系统属性(SystemProperties)【转】
本文转载自:https://blog.csdn.net/wei_lei/article/details/70312512 Android.os.SystemProperties 提供了获取和设置系统属 ...
- 淘宝分类常见---部分显示和全部显示的js效果
需求就是,点击“更多按钮”,显示全部的分类详情,再次点击,显示部分分类. 展开: 收起: 结构: <div class="SubBox" id="SubBox&qu ...
- thinkphp 多表事务处理
try{ $this->user = D('User'); $this->user->startTrans(); //开始事务 $res = $this->user->S ...
- R语言笔记005——计算描述性统计量
数据的分布特征: 分布的集中趋势,反应各数据向其中心值靠拢或聚集的程度(平均数,中位数,四分位数,众数) 分布的离散程度,反应各数据远离其中心值的趋势(极差,四分位差,方差,标准差,离散系数) 分布的 ...
- R语言学习笔记(1)
第一章:R语言介绍 一 R的使用 1 R是一种区分大小写的解释型语言.R语句由函数和赋值构成.R使用<-作为赋值符号.例如: x<-rnorm(5) 创建了一个名为x的向量对象,它包含5个 ...