msid is a Ruby gem for generating a unique and secure machine fingerprint ID. It gathers a wide range of system identifiers to create a hash that is highly specific to the machine it's run on.
This is useful for licensing, device identification, or any scenario where you need to reliably identify a specific machine.
msid collects the following system information:
- Hostname
- All MAC addresses
- CPU model and core count
- Total RAM
- OS and kernel information
- Hardware Serial Number
- Hardware UUID
- Motherboard Serial Number
- Root disk volume UUID
- System Model Identifier
- GPU Information
- BIOS/Firmware Information
- Serial numbers of all physical disks
It then combines these components into a single string and uses the SHA-256 algorithm to produce a consistent, unique fingerprint.
Here are some practical scenarios where msid can be valuable:
- Offline License Activation: Bind software licenses to specific machines without requiring constant internet validation.
- Trial Period Management: Track installations to prevent users from repeatedly installing trial versions.
- License Auditing: Keep track of which machines have your software installed for compliance purposes.
- Multi-factor Authentication: Add an extra layer of security by validating not just "something you know" (password) but also "something you have" (the specific device).
- Session Security: Detect when a user's session moves to a different machine, potentially indicating session hijacking.
- Fraud Detection: Flag accounts that suddenly access your service from multiple different machines in rapid succession.
- Asset Tracking: Inventory management for IT departments to track hardware across an organization.
- Configuration Management: Associate specific configurations or settings with particular machines.
- Environment-specific Features: Enable or disable features based on the hardware environment.
- Environment Fingerprinting: Distinguish between development, staging, and production environments.
- Deployment Validation: Ensure that deployments only happen from authorized build machines.
- Infrastructure Auditing: Track which servers or virtual machines are running your applications.
- Device Demographics: Gather anonymous statistics about what kinds of machines are running your software.
- Installation Metrics: Track unique installations versus reinstallations.
- Hardware Compatibility: Identify hardware configurations where your software performs well or poorly.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
You can generate the machine ID from your Ruby code.
For enhanced security, you can provide a salt. This is useful if you want to generate different IDs for different applications on the same machine.
If you are developing the gem locally, you can test it with irb. From the root directory of the gem, run irb with the -I flag to add the lib directory to Ruby's load path.
Then, inside irb, you can require and use the gem:
To use msid in a Rails application, add it to your Gemfile.
If you are developing the gem locally, you can use the path option:
If the gem is on RubyGems, add it normally:
Then run bundle install.
Now you can use it anywhere in your Rails application, including the Rails console:
The gem provides a command-line executable to easily retrieve the machine ID.
After checking out the repo, run bundle install to install dependencies. Then, run rake test to run the tests.
Bug reports and pull requests are welcome on GitHub at https://github.com/davidesantangelo/msid.
The gem is available as open source under the terms of the MIT License.
.png)


