I am trying to follow this tutorial to create a login for node red.
From what I can gather node-red admin is built into node red so why would I need to install a package? I get an error when using the tutorial code trying
npm install -g --unsafe-perm node-red-admin
Linux terminal this command works from the tutorial code:
node-red-admin hash-pw
To retrieve the password hash
and sudo nano ~/.node-red/settings.js
following the tutorial to uncomment the correct lines on my end it looks like this:
/** To password protect the Node-RED editor and admin API, the following
* property can be used. See http://nodered.org/docs/security.html for details.
*/
adminAuth: {
type: "credentials",
users: [{
username: "ben",
password: "supersecretP@$$word",
permissions: "*"
}]
},
/** The following property can be used to enable HTTPS
* This property can be either an object, containing both a (private) key
* and a (public) certificate, or a function that returns such an object.
* See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
* for details of its contents.
*/
And then thru nano writing the file and doing a sudo reboot
I cant login with this username and password, any ideas to try?
The password you are storing in your settings.js file should be a hash that is generated from your password. You can generate this hash with the tool from your cli use
node-red-admin hash-pw
or
node -e "console.log(require('bcryptjs').hashSync(process.argv[1], 8));" your-password-here
After entering your password a string of hash will appear, copy it and insert it in the settings file:
adminAuth: {
type: "credentials",
users: [{
username: "ben",
password: "$2b$08$wuAqPiKJlVN27eF5qJp.RuQYuy6ZYONW7a/UWYxDTtwKFCdB8F19y",
permissions: "*"
}]
},
It should look something like this.
I suggest you to read the documentation page in-depth to properly secure your node-red instance before opening it to public use.