A lightweight crate for retrieving the unique machine ID without needing root/admin privileges.
IDs sources
- Windows: the
MachineGuidvalue fromHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography(Identifying Unique Windows Installation) - Linux:
/etc/machine-idwith a fallback to/var/lib/dbus/machine-id(man page)
- BSD /etc/hostid and smbios.system.uuid as a fallback
- macOS and OSX
IOPlatformExpertDevice? - Android
Security Considerations
A machine ID uniquely identifies the host and should be treated as confidential, avoiding exposure in untrusted environments. If your application requires a stable unique identifier, avoid using the machine ID directly. Instead, hash the machine ID securely with a fixed, application-specific salt.
[!TIP]
Virtual machines deployed from the same template often share the same machine ID. To differentiate them, include the MAC address when hashing.