title: Extract Publickey from Privatekey input using Python
body: <p>I need to generate publickey from a private key without temporary location locally like we do in sshgen.So i use this.Here iam passing my private key as input like this(while executing):</p>
  
  <pre><code>python codekey.py "-----BEGIN RSA PRIVATE KEY-----\nMIhhhhhhhhhhhhhhhh......Bidqt/YS3/0giWrtv+rMkJtv8n\nmirJ+16SZodI5gMuknvZG....................n-----END RSA PRIVATE KEY-----"
  </code></pre>
  
  <p>My code (codekey.py): </p>
  
  <pre><code>import sys
  import io
  from twisted.conch.ssh import keys
  k = sys.argv[1]
  rsa = keys.RSA.importKey(k)
  key = keys.Key(rsa)
  ssh_public = key.public().toString("openssh")
  print ssh_public
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>      Traceback (most recent call last):
      File "codekey.py", line 7, in &lt;module&gt;
       rsa = keys.RSA.importKey(k)
      File "/usr/lib/python2.7/dist-packages/Crypto/PublicKey/RSA.py", line                638, in importKey
       if lines[1].startswith(b('Proc-Type:4,ENCRYPTED')):
         IndexError: list index out of range
  </code></pre>
  
  <p>Dyanamically i need to pass key value as shown above while executing my python script and from that it will generate public key .Whether it is possible ??,i dont need to store locally,since for priveleges and key securities,dont want to hack.</p>