-1

Presently I'm checking by running dmidecode -s bios-version and grepping against major cloud vendors. Ex: # From an amazon ec2 VM $ sudo dmidecode -s bios-version 4.2.amazon

Is there a generic and more reliable approach for finding this?

1

There is no standard mechanism by which cloud vendors inject identification into running virtual machines. If your goal is to detect whether or not your are running in a virtual environment you could use the virt-what command, but there is no good way to differentiate one cloud vendor from another.

0

Here is a piece of code using which you can detect the popular bare metal vendors like AWS, Azure, Google Cloud and Oracle. This will return None if it cannot detect cloud. https://github.com/nithinj/cloud_what

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.