本文共 1752 字,大约阅读时间需要 5 分钟。
/****************************************************************************** * Busybox shell脚本修改密码 * 说明: * 需要在在Busybox文件系统中修改密码,但是passwd命令需要交互才能修改密码, * 原来Busybox提供了chpasswd命令,在shell中直接用passwd也是可行的。 * * 2017-3-9 深圳 南山平山村 曾剑锋 *****************************************************************************/一、参考文档: 1. how to change password with shell script in busybox 1.4.2 http://www.avrfreaks.net/forum/how-change-password-shell-script-busybox-142 2. 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 3. 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 (2016-09-21 23:53:28 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. 方法1: compile your own busybox configuration with chpasswd command。 2. 方法2: 1. 编写一个脚本如下: #!/bin/sh passwd << EOFEOF 2. 输出效果如下 [zengjf@root ~]# ./chpasswd Changing password for root New password: Bad password: too weak Retype password: passwd: password for root changed by root [zengjf@root ~]#
转载地址:http://qpchx.baihongyu.com/