The Internet of Things

Node-Red Security

Log in to the Raspberry Pi using Putty

Stop Node-Red

  • sudo systemctl disable nodered.service
  • node-red-stop
  • sudo reboot & exit

Generating new SSH keys

  • cd .node-red (cd /home/pi/.node-red or cd ~/.node-red)
  • openssl genrsa -out privatekey.pem 1024
  • openssl req -new -key privatekey.pem -out private-csr.pem
  • openssl x509 -req -days 365 -in private-csr.pem -signkey privatekey.pem -out certificate.pem
  • ls -all and you find 3 new files:
    • certificate.pem
    • private-csr.pem
    • privatekey.pem

 Update settings.js

  • nano settings.js
  • uncomment lines:
    • var fs=required("fs");
    • https: {
    • key: fs.readFileSunc('/home/pi/.node-red/privatekey.pem')
    • cert: fs.readFileSunc('/home/pi/.node-red/certificate.pem')
    • },
    • adminAuth: {
    • type: "credentials",
    • users: [{
    • Username: "admin",
    • password: " --- ",
    • permissions: "*"
    • }]
    • },
  • save & exit settings.js 

Install node-red-admin

  • su (to log as root)
  • npm install -g node-red-admin
  • exit
  • pwd
  • cd .node-red
  • node-red-admin hash-pw
Enter the password you want, copy the hash code and save this to the 'password' line in the settings.js file.

Start Node-red

  • sudo systemctl enable nodered.service
  • node-red-start
Now you cane see Node-red in your browser by using https://'ip adres raspberry pi':1880
and login with admin and your password.

No comments:

Post a Comment