diff --git a/paramiko/pkey.py b/paramiko/pkey.py index f494c80e8..9f9cc5436 100644 --- a/paramiko/pkey.py +++ b/paramiko/pkey.py @@ -324,7 +324,9 @@ def _read_private_key_file(self, tag, filename, password=None): def _read_private_key(self, tag, f, password=None): lines = f.readlines() - + if not lines: + raise SSHException("no lines in {} private key file".format(tag)) + # find the BEGIN tag start = 0 m = self.BEGIN_TAG.match(lines[start])