To view the certificate Modulus:
openssl x509 -noout -modulus -in [certificate-file.crt]
To view the key Modulus:
openssl rsa -noout -modulus -in [key-file.key]
Command to compare certificate vs private key
$ certMod=$(openssl x509 -text -noout -modulus -in server.crt | grep "Modulus=") && \ keyMod=$(openssl rsa -text -noout -modulus -in server.key | grep "Modulus=") && \ [[ $certMod == $keyMod ]] && echo "Equal"
Tribut to Peter Mescalchin magnetikonline for the script above https://gist.github.com/magnetikonline/fbdb26fcb34ca5038c03507cbdfdb534