Authentication between Node Exporter and Prometheus

On Node Exporter - install apache2-utils:

sudo apt install apache2-utils
Create a hash:
$ htpasswd -nBC 12 "" | tr -d ":\n"
New password: test
Re-type new password: test
$2y$12$glP7uUEncFrd0X8ZSuGFVuyyAE3FnM11O/FDXICiIp/GQmig5LoFK
Use this hash in Node Exporter configuration at /etc/node_exporter/config.yml:
...
basic_auth_users:
  prometheus: $2y$12$glP7uUEncFrd0X8ZSuGFVuyyAE3FnM11O/FDXICiIp/GQmig5LoFK
...
Restart Node Exporter:
sudo systemctl restart node_exporter
In the Prometheus UI this Node Exporter will show as 401 Unauthorized. So we need to configure Prometheus at /etc/prometheus/prometheus.yml:
...
  - job_name: 'Node_Exporter'
    scrape_interval: 5s
    basic_auth:
      username: prometheus
      password: test
...
And restart it:
sudo systemctl restart prometheus
Finally, check Prometheus UI