Skip to content

Instantly share code, notes, and snippets.

@MichalMazurek
Created October 11, 2019 10:18
Show Gist options
  • Save MichalMazurek/c61fd1bb205836341b3609bb921fdf88 to your computer and use it in GitHub Desktop.
Save MichalMazurek/c61fd1bb205836341b3609bb921fdf88 to your computer and use it in GitHub Desktop.
def _read_private_key(self, tag, f, password=None):
lines = f.readlines()
start = 0
beginning_of_key = "-----BEGIN " + tag + " PRIVATE KEY-----"
while start < len(lines) and lines[start].strip() != beginning_of_key:
start += 1
if start >= len(lines):
raise SSHException("not a valid " + tag + " private key file")
# parse any headers first
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment