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是要被修改的文件
随机推荐
- offsetHeight+scrollHeight+clientHeight
ch 窗口可见区域高度 :ch = padding + height(height不是所有内容的高度,是样式定义的高度) oh border以内的内容高度: oh = border + padding ...
- position:absolute width
position:absolute; left:0px; right:0px; top:0px; bottom:0px; 设置布满整个父范围,设置了absolute的元素可以通过以上4个属性来展开面, ...
- linux mint —— 图片一张
概述 Linux Mint是一種基於Ubuntu開發出的Linux操作系统.由Linux Mint Team团队于2006年开始发行.Linux Mint 的目标是为家庭用户和企业客户提供一个免费.高 ...
- Linux doxygen的安装与使用
1.安装doxygen 目前最新版本的的doxygen是doxygen1.8.13,安装包可以在官网上下载,网址是:http://www.stack.nl/~dimitri/doxygen/downl ...
- Linux Shell编程 awk命令
概述 awk是一种编程语言,用于在linux/unix下对文本和数据进行处理.数据可以来自标准输入(stdin).一个或多个文件,或其它命令的输出.它支持用户自定义函数和动态正则表达式等先进功能,是l ...
- java基础—— Collections.sort的两种用法
package com.jabberchina.test; import java.util.ArrayList; import java.util.Collections; import java. ...
- 【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 ...
- 【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 ...
- Linux下SPI测试程序
/** 说明:SPI通讯实现* 方式一: 同时发送与接收实现函数: SPI_Transfer()* 方式二:发送与接收分开来实现* SPI_Write() 只发送* SPI_Read() 只接收* 两 ...
- vue项目的webpack设置请求模拟数据的接口方法
最近在跟着视频写饿了吗vue项目,其中模拟数据由于webpack版本变化,跟视频中不一致,下方博客有解决方案,其实视频里面的还能看懂,现在webpack的服务都在插件包里了,好难找. 请参考:http ...