Ubuntu Linux machine-id
Introduction
The file
/etc/machine-id
contains the unique identifier of the local system, the machine ID.
The machine ID is set during the installation or boot of Ubuntu.
The machine ID is a single hexadecimal identifier ending in a newline, consisting of 32 lower-case characters.
Decoded from hexadecimal it corresponds to a 16-byte/128-bit value.
This identifier cannot consist of zeros only.
The machine ID is usually generated from a random source during system installation or the first boot and stays the same for all subsequent boots.
For stateless systems it can be generated at run time during early boot if necessary.
The machine ID can be set, for example, on network boot with a kernel command line parameter
systemd.machine_id=
Or by passing the parameter --machine-id= to systemd.
The identifier set in this way has a higher priority and is used instead of the one stored in
/etc/machine-id
.
The machine ID does not change with the local or network configuration or when the hardware is replaced.
Because of this property, and because it is longer, it is a more useful replacement for the gethostid(3) call specified in POSIX.
This machine ID follows the same format and logic as the D-Bus machine ID.
This identifier uniquely identifies the host. It should be considered confidential and should not be exposed in untrusted environments, in particular on the network.
If some application needs a unique identifier tied to the machine, the machine ID or any part of it must not be used directly.
Instead the machine ID should be hashed with a keyed cryptographic hash function, using a fixed key specific to the application.
In this way the identifier is properly unique and permanently derived from the machine ID, but there is no way to obtain the original machine ID from a particular application.
The API sd_id128_get_machine_app_specific(3) provides an implementation of such an algorithm.
Find out your machine-id
cat /etc/machine-id
4ab7d70cacd0d33ca5bc9b2344e5e328
Change machine-id
Delete the old machine-id
sudo rm /etc/machine-id
Generate a new machine-id
sudo systemd-machine-id-setup
Check the result
cat /etc/machine-id
Now it is better to reboot and check that everything works correctly
Creating a new machine-id
If you deleted the machine-id you can create a new one with the command
systemd-machine-id-setup
Change machine-id
If the same id is generated all the time it is most likely taken from somewhere else
You can generate it yourself with dbus--uuidgen
rm -f /etc/machine-id
dbus-uuidgen --ensure=/etc/machine-id
dbus-uuidge --ensure
cat /etc/machine-id
Article author: Andrei Olegovich