Node.js命令行/批處理中如何更改Linux用戶密碼淺析
前言
本文主要介紹了Node.js命令行/批處理更改Linux用戶密碼的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面話不多說了,來一起看看詳細(xì)的介紹吧
hpasswd 可在批處理文件中批量更改Linux用戶的密碼。
用法:
chpasswd [options]
option主要為一些密碼加密選項(xiàng)
-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 格式輸入用戶名密碼,一行一個(gè),如:
chpasswd newghost:4567
用這種方法可在node.js中使用:
var cp = require('child_process')
//更新密碼
var chpasswd = cp.spawn('chpasswd')
var errmsg
//查看是否有錯(cuò)誤
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í)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。
相關(guān)文章
Ubuntu中搭建Nodejs開發(fā)環(huán)境過程分享
這篇文章主要介紹了Ubuntu中搭建Nodejs開發(fā)環(huán)境過程,比較郁悶的是apt-get安裝失敗了,如果有遇到一樣問題的朋友,可以參考一下本文2014-06-06
基于socket.io+express實(shí)現(xiàn)多房間聊天
本文給大家分享的是使用node.js,基于socket.io+express實(shí)現(xiàn)多房間聊天的代碼,非常的實(shí)用,有需要的小伙伴可以來參考下2016-03-03
Node.js中的http請求客戶端示例(request client)
本篇文章主要介紹了Node.js中的http請求客戶端示例(request client),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05
手動(dòng)下載Chrome并解決puppeteer無法使用問題
本篇文章主要介紹了手動(dòng)下載Chrome并解決puppeteer無法使用問題,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-11-11
Node.js自動(dòng)生成API文檔的實(shí)現(xiàn)
本文主要介紹了Node.js自動(dòng)生成API文檔,包含基于swagger-jsdoc+swagger-ui-express快速實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下2024-03-03

