zoukankan      html  css  js  c++  java
  • Busybox shell脚本修改密码

    /******************************************************************************
     *                        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 << EOF 
                <new password> 
                <new password> 
                EOF 
            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 ~]#  
            
  • 相关阅读:
    Phone List(字典树)
    Dating with girls(1)(二分+map+set)
    Color the ball(树状数组+线段树+二分)
    python模块导入总结
    Python爬虫之定时抢购淘宝商品
    Celery多队列配置
    python垃圾回收机制
    python变量、对象和引用你真的明白了吗
    使用 supervisor 管理 Celery 服务
    Supervisor的作用与配置
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/6525613.html
Copyright © 2011-2022 走看看