title: How to check a public RSA key file
body: <p>Inside a shell script I want verify public RSA file.
  All I want to do is that find a way to check this file is a genuine public key file, nothing else.</p>
  
  <p>Can I ask experts here what are the ways I can verify this input file to check this is a genuine public key file , not a regular file. </p>
  
  <p>I will be using this public key file in future to validate an incoming encrypt gzip file but that is out of scope for now.</p>
  
  <p>All I want is validate input file to check its genuine RSA public key file not an ordinary file.please note that I do not have any other files with me (eg : private key) .</p>
  
  <p>e.g.: if the file is <code>‘public.pem’</code> I just want check inside that it’s a genuine RSA public key file not just a file with texts or file is not corrupted .
  I’m already checking that file is not zero sized and md5 . </p>
  
  <p>other possible checks I found 
  check file got text <code>‘BEGIN PUBLIC KEY’</code> and <code>‘END PUBLIC KEY’</code>
  Also found this command in google , Is there a better way to do this using openssl </p>
  
  <pre><code>‘openssl rsa -noout -text -inform PEM -in pubkey.pem -pubin’
  </code></pre>
  
  <p>Thanks</p>