Ubuntu – How to generate unique hardware hash

hardware

I wanna know that is there's a way, by which we can generate a unique hardware hash of particular machine? The hash should be unique to the machine and hash should be different even two machines are of same configuration. Is it possible?

Best Answer

You could use the MAC address of eth0 (assuming this exists on each machine). You can get that on its own (there may be a simpler way) with this:

ifconfig eth0 | grep HWaddr | awk '{ print $NF}' | sed 's/://g'

That will give you something like 6cf04954aaaa.

These are supposed to be unique but they're not always. If all your network hardware comes from the same manufacturer, you might find some crossover, so be careful with it.


Failing that, you could generate your own unique string and store it in /etc/computer-id (or another path of your choosing).

uuidgen -r

Will generate something as random as possible eg: 52a85807-35fe-409e-8983-87eb58c02ece

uuidgen -t

Uses time and eth0's MAC to make something like: eb8280dc-b5ec-11e0-90dd-6cf04954aaaa

Both are fairly unique but, as with anything random, there is always the possibility of a clash. Keep a central list to avoid problems like this.

Related Question