/******************************************************************************
* 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. offsetHeight+scrollHeight+clientHeight

    ch 窗口可见区域高度 :ch = padding + height(height不是所有内容的高度,是样式定义的高度) oh border以内的内容高度: oh = border + padding ...

  2. position:absolute width

    position:absolute; left:0px; right:0px; top:0px; bottom:0px; 设置布满整个父范围,设置了absolute的元素可以通过以上4个属性来展开面, ...

  3. linux mint —— 图片一张

    概述 Linux Mint是一種基於Ubuntu開發出的Linux操作系统.由Linux Mint Team团队于2006年开始发行.Linux Mint 的目标是为家庭用户和企业客户提供一个免费.高 ...

  4. Linux doxygen的安装与使用

    1.安装doxygen 目前最新版本的的doxygen是doxygen1.8.13,安装包可以在官网上下载,网址是:http://www.stack.nl/~dimitri/doxygen/downl ...

  5. Linux Shell编程 awk命令

    概述 awk是一种编程语言,用于在linux/unix下对文本和数据进行处理.数据可以来自标准输入(stdin).一个或多个文件,或其它命令的输出.它支持用户自定义函数和动态正则表达式等先进功能,是l ...

  6. java基础—— Collections.sort的两种用法

    package com.jabberchina.test; import java.util.ArrayList; import java.util.Collections; import java. ...

  7. 【HackerRank】Sherlock and Array

    Watson gives an array A1,A2...AN to Sherlock. Then he asks him to find if there exists an element in ...

  8. 【HackerRank】 Game Of Thrones - I

    King Robert has 7 kingdoms under his rule. He gets to know from a raven that the Dothraki are going ...

  9. Linux下SPI测试程序

    /** 说明:SPI通讯实现* 方式一: 同时发送与接收实现函数: SPI_Transfer()* 方式二:发送与接收分开来实现* SPI_Write() 只发送* SPI_Read() 只接收* 两 ...

  10. vue项目的webpack设置请求模拟数据的接口方法

    最近在跟着视频写饿了吗vue项目,其中模拟数据由于webpack版本变化,跟视频中不一致,下方博客有解决方案,其实视频里面的还能看懂,现在webpack的服务都在插件包里了,好难找. 请参考:http ...