资源共享,记录个人心得等

Linux生成密文密码

1.通过ansible

 ansible all -i localhost, -m debug -a "msg={{ '123456' | password_hash('sha512', 'oldboy') }}"
  localhost | SUCCESS => {
      "msg": "$6$oldboy$MVd3DevkLcimrBLdMICrBY8HF82Wtau5cI8D2w4Zs6P1cCfMTcnnyAmmJc7mQaE9zuHxk8JFTRgYMGv9uKW7j1"
    }

2.通过mkpasswd

 mkpasswd --method=sha-512

3.通过passlib需要python

 yum install -y python-pip
    pip install passlib
    python -c "from passlib.hash import sha512_crypt; import getpass; print(sha512_crypt.using(rounds=5000).hash(getpass.getpass()))"
    Password:
    $6$rJJeiIerQ8p2eR82$uE2701X7vY44voF4j4tIQuUawmTNHEZhs26nKOL0z39LWyvIvZrHPM52Ivu9FgExlTFgz1VTOCSG7KhxJ9Tqk.

4.通过htpasswd

需要安装“httpd-tools”,安装httpd时会自动安装

 htpasswd -bc ./htpasswd user1 123456

htpasswd命令参数说明:

       -c  Create a new file.  *****
      创建一个密码文件
      -n Don't update file; display results on stdout.
      不会更新文件; 显示文件内容信息
      -b Use the password from the command line rather than prompting for it. *****
      免交互方式输入用户密码信息
      -i Read password from stdin without verification (for script usage).
      读取密码采用标准输入方式,并不做检查 ???
      -m Force MD5 encryption of the password (default).
      md5的加密算法
      -B Force bcrypt encryption of the password (very secure).
      使用bcrypt对密码进行加密  
      -C Set the computing time used for the bcrypt algorithm
          (higher is more secure but slower, default: 5, valid: 4 to 31).
  使用bcrypt algorithm对密码进行加密
      -d Force CRYPT encryption of the password (8 chars max, insecure).
      密码加密方式
      -s Force SHA encryption of the password (insecure).
      加密方式
      -p Do not encrypt the password (plaintext, insecure).
      不进行加密
      -D Delete the specified user.
      删除指定用户
      -v Verify password for the specified user.
赞(0)
转载需标明出处Lee's Blog » Linux生成密文密码

评论 抢沙发

登录

找回密码

注册