/******************************************************************************
* 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脚本修改密码的更多相关文章

  1. Linux 通过 shell 脚本修改密码

    交互方式修改密码 1. ssh 远程到主机: 2. 切换到root账号: [一般都是切换到root进行密码修改,如果普通用户修改自己的密码,要输入原密码,然后新密码要满足复杂度才OK]: 3. pas ...

  2. Mac下通过shell脚本修改properties文件

    通过shell脚本替换属性文件中的某行记录 假设有如下属性文件 demo.properties user.name=test user.password=123456 ................ ...

  3. shell脚本修改文本中匹配行之前的行的方法

    原创文件,欢迎阅读,禁止转载. 例子中是把 finish 前一行的 "yes" 改成 "YES"有一个方法就是利用sed+awk一起来完成. zjk@zjk:~ ...

  4. salt 执行shell 脚本 修改名字

    #!/bin/bash #命令 匹配主机 执行模块 脚本路径,必须放在salt目录下 源主机名 修改的主机名 #salt tt_LD_LM_LC_1 cmd.script salt://init/re ...

  5. Shell 脚本修改 Mac IP地址

    本篇文章由:http://xinpure.com/shell-script-to-modify-the-mac-ip-address/ 麻烦事 最近在笔记本 WIFI 网络上遇到一个麻烦事, 在公司需 ...

  6. shell脚本明文密码隐藏且加密

    将密码放到文件中去,比如/root/.pass.txtpassword=`</root/.pass.txt`还怕密码泄露的话,就把pass.txt权限设置下. chattr +i /root/. ...

  7. 〖Linux〗Shell脚本修改输出文字颜色

    Shell函数: echocolor(){ color=${} && shift case ${color} in black) echo -e "\e[0;30m${@}\ ...

  8. shell脚本修改文件

    https://blog.csdn.net/qq_37674858/article/details/80066264 2.2 使用sed命令对文件中的字符替换 例如:将aaaa字符串修改为bbbb [ ...

  9. linux通过shell脚本修改文件内容

    sed -i 's/abc/xxx/g' file abc修改前的字符串xxx是修改后的字符串file是要被修改的文件

随机推荐

  1. Computer Information

    Lab: lxw@lxw-PC:python$ df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda7 190G .4G 175G % / none .0K .0K % /sys/ ...

  2. MVC4 中使用 Area 和 注意的地方

    在MVC项目中经常会使用到Area来分开不同的模块让项目结构更加的清晰. 步骤如下:  项目 –> 添加 -> 区域 (Area)  输入 Admin 添加成功后 Area包含:创建一个空 ...

  3. 基于R语言的数据分析和挖掘方法总结——均值检验

    2.1 单组样本均值t检验(One-sample t-test) 2.1.1 方法简介 t检验,又称学生t(student t)检验,是由英国统计学家戈斯特(William Sealy Gosset, ...

  4. linux 网卡buffer大小

    参考截取一部分:https://blog.csdn.net/ysu108/article/details/7764461 在linux下可以修改协议栈改变tcp缓冲相关参数: 修改系统套接字缓冲区 e ...

  5. VMware 连接不上XSHELL

    本人创建虚拟机时把网络连接模式选成了桥接,后来在VMware虚拟网络编辑器中查看了连接模式:NAT. 重新回到VMware中更改了连接模式:NAT模式 成功连接XSHELL 步骤1 打开VMware的 ...

  6. INSPIRED启示录 读书笔记 - 第39章 打造平台产品的经验

    最具挑战性的工作 产品管理中难度最大,也最能体现产品经理实力的是定义成功的平台产品.所谓平台产品是指一类基础软件,应该开发者能在其基础上开发应用程序 平台产品要面对三种不同的客户 1.应用软件供应商: ...

  7. Android系统--输入系统(一)必备的Linux知识_inotify和epoll

    Android系统--输入系统(一)必备的Linux知识_inotify和epoll 引入 1. 笔记本电脑插入外接键盘,两个键盘都可以使用 a. 键盘即插即用--如何检测键盘的接入和拔出 hotpl ...

  8. Android系统属性SystemProperties在应用层的用法【转】

    本文转载自:https://blog.csdn.net/lilidejing/article/details/53288243 如果你看到这篇文章了,说明你已经是资深程序员,会发现整个Android系 ...

  9. eclipse oxygen 版本(即为4.7版本)打开 could not create the java virtual machine问题

    1.问题: could not create the java virtual machine 2.解决办法: 找到eclipse目录下的eclipse.ini文件.打开找到以下内容: -vmargs ...

  10. Struts2获取参数的几种方式

    Struts2由于是一个贴心的框架,所以获取参数这种体力活,就无需再通过原生的request来getParameter了,有如下几种方式进行获取 1.Action中属性驱动,必须提供与form表单na ...