A simple Bash script that installs Node Exporter on a remote Linux server via SSH and automatically configures it as a systemd service.
Before running the script, download the desired Node Exporter release from the official GitHub releases page:
https://github.com/prometheus/node_exporter/releases
This script is configured by default for Node Exporter v1.8.1.
Download the archive:
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.1/node_exporter-1.8.1.linux-amd64.tar.gzExtract the archive:
tar -xzf node_exporter-1.8.1.linux-amd64.tar.gzAfter extraction, your directory should look similar to:
.
├── install_node_exporter.sh
├── node_exporter-1.8.1.linux-amd64.tar.gz
└── node_exporter-1.8.1.linux-amd64/
└── node_exporter
⚠️ Important:The script expects the extracted Node Exporter binary to exist at:
node_exporter-1.8.1.linux-amd64/node_exporter
Grant execute permissions:
chmod +x install_node_exporter.shExecute:
./install_node_exporter.shThe script will prompt for the following information:
Example:
192.168.1.100
Examples:
root
ubuntu
Default:
22
Custom:
2222
If left blank, the script automatically uses 22.
- Verifies that the Node Exporter binary exists locally.
- Copies the binary to the remote server using SCP.
The script automatically:
-
Creates a dedicated
node_exporteruser if it does not already exist. -
Moves the binary to:
/usr/local/bin/node_exporter -
Sets ownership and permissions.
-
Creates a systemd service file.
-
Reloads systemd.
-
Enables Node Exporter to start on boot.
-
Starts the service immediately.
-
Displays the service status.
The remote SSH user must:
- Have SSH access to the target server.
- Have sudo privileges.
- Be allowed to execute administrative commands such as:
sudo useradd
sudo mv
sudo tee
sudo systemctlCheck service status:
sudo systemctl status node_exporterCheck whether Node Exporter is listening on port 9100:
ss -tulpn | grep 9100or
netstat -tulpn | grep 9100From your Prometheus server or any machine with network access:
curl http://SERVER_IP:9100/metricsIf the installation was successful, you should see Prometheus metrics output similar to:
# HELP go_gc_duration_seconds ...
# TYPE go_gc_duration_seconds summary
...
The script is configured by default for v1.8.1:
NODE_EXPORTER_PATH="node_exporter-1.8.1.linux-amd64/node_exporter"To use a different version:
- Download the desired Node Exporter release.
- Extract the archive.
- Update the
NODE_EXPORTER_PATHvariable inside the script.
Example:
NODE_EXPORTER_PATH="node_exporter-1.9.0.linux-amd64/node_exporter"You may also update any version references in the documentation if desired.
This makes the script easy to adapt for newer Node Exporter releases.
If you see:
❌ Node Exporter binary not found
Make sure the archive has been extracted and that the following file exists:
node_exporter-1.8.1.linux-amd64/node_exporter
Ensure the SSH user has sudo privileges on the remote server.
Inspect the service logs:
sudo journalctl -u node_exporter -fAfter a successful installation:
- Node Exporter runs as a dedicated system user.
- The service starts automatically after reboot.
- Metrics are exposed on port 9100.
- The server is ready to be scraped by Prometheus.
Default metrics endpoint:
http://SERVER_IP:9100/metrics