Node.js命令行/批處理中如何更改Linux用戶密碼淺析
前言
本文主要介紹了Node.js命令行/批處理更改Linux用戶密碼的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面話不多說了,來一起看看詳細的介紹吧
hpasswd 可在批處理文件中批量更改Linux用戶的密碼。
用法:
chpasswd [options]
option主要為一些密碼加密選項
-c, --crypt-method
Use the specified method to encrypt the passwords.
The available methods are DES, MD5, NONE, and SHA256 or SHA512 if your libc support these methods.
-e, --encrypted
Supplied passwords are in encrypted form.
-h, --help
Display help message and exit.
-m, --md5
Use MD5 encryption instead of DES when the supplied passwords are not encrypted.
-s, --sha-rounds
Use the specified number of rounds to encrypt the passwords.
The value 0 means that the system will choos
輸入命令后,按 username:password
格式輸入用戶名密碼,一行一個,如:
chpasswd newghost:4567
用這種方法可在node.js中使用:
var cp = require('child_process') //更新密碼 var chpasswd = cp.spawn('chpasswd') var errmsg //查看是否有錯誤 chpasswd.stderr.on('data', function (data) { errmsg += data.toString() }) chpasswd.on('exit', function(code) { if (cb) { errmsg ? cb(new Error(errmsg)) : cb() } }) //寫入密碼 chpasswd.stdin.write(username + ':' + password) chpasswd.stdin.end()
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。
相關(guān)文章
Node.js連接mongo數(shù)據(jù)庫上傳文件的方法步驟
本文主要介紹了Node.js連接mongo數(shù)據(jù)庫上傳文件的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05node.js中 mysql 增刪改查操作及async,await處理實例分析
這篇文章主要介紹了node.js中 mysql 增刪改查操作及async,await處理,結(jié)合實例形式分析了node.js中 mysql庫安裝、增刪改查操作及async,await處理相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2020-02-02Nodejs搭建多進程Web服務(wù)器實現(xiàn)過程
這篇文章主要為大家介紹了Nodejs搭建多進程Web服務(wù)器實現(xiàn)過程詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-10-10利用Mongoose讓JSON數(shù)據(jù)直接插入或更新到MongoDB
這篇文章主要給大家介紹了利用Mongoose讓JSON數(shù)據(jù)直接插入或更新到MongoDB數(shù)據(jù)庫的相關(guān)資料,文中詳細介紹了配置Mongoose、創(chuàng)建目錄及文件、插入數(shù)據(jù),POST提交JSON增加一條記錄以及詢數(shù)據(jù),取出剛增加的記錄等內(nèi)容,需要的朋友可以參考下。2017-05-05express express-session的使用小結(jié)
這篇文章主要介紹了express express-session的使用小結(jié),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-12-12使用nodejs?spider爬取圖片及數(shù)據(jù)實現(xiàn)
這篇文章主要為大家介紹了使用nodejs?spider爬取圖片及數(shù)據(jù)實現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-07-07利用nodeJs anywhere搭建本地服務(wù)器環(huán)境的方法
今天小編就為大家分享一篇利用nodeJs anywhere搭建本地服務(wù)器環(huán)境的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-05-05