1

seems Cygwin doesn't make a /etc/machine-id by default, how should i get a /etc/machine-id on Cygwin? i guess doing

php -r 'echo bin2hex(random_bytes(16));' > /etc/machine-id

is close enough? but if there's a package or an official way to get it, i'm all ears

hanshenrik
  • 1,925
  • 3
  • 25
  • 38

1 Answers1

1

There are no specific requirements for the machine ID in /etc/machine-id, so any method that produces 32 hexadecimal digits will work.

Though the tools that come with systemd do use the UUIDv4 format, which has a few specific bits set here and there, so uuidgen | sed s/-//g > /etc/machine-id would be a "closer" choice, but that's not required (and older systemd versions didn't do it either, they used to just generate fully random IDs).

Alternatively, you could get the 'MachineGuid' field from HKLM\SOFTWARE\Microsoft\Cryptography in the Registry and write it to the machine-id file. That seems to be what this Rust crate does.

But don't forget that your system has a hostname. It's often easier for shell scripts to check the local system's hostname than look up its machine-id. PHP has gethostname() for that.

grawity
  • 501,077