您好,登錄后才能下訂單哦!
前言
本文主要介紹了Node.js命令行/批處理更改Linux用戶密碼的相關(guān)內(nèi)容,分享出來(lái)供大家參考學(xué)習(xí),下面話不多說(shuō)了,來(lái)一起看看詳細(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é)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。