Skip to content

misleading exception: not a valid EC private key file #521

@p-tr0

Description

@p-tr0

When the key I try to use is not added to authorized_keys on the remote host,
and ~/.ssh/id_rsa on a local host doesn't exist but key_filename is provided instead
misleading 'not a valid EC private key file' exception is rised

Here's some traceback:

  File "/home/test/venv/lib/python3.4/site-packages/paramiko/client.py", line 307, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/client.py", line 519, in _auth
    raise saved_exception
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/client.py", line 444, in _auth
    key = pkey_class.from_private_key_file(key_filename, password)
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/pkey.py", line 183, in from_private_key_file
    key = cls(filename=filename, password=password)
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/ecdsakey.py", line 49, in __init__
    self._from_private_key_file(filename, password)
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/ecdsakey.py", line 147, in _from_private_key_file
    data = self._read_private_key_file('EC', filename, password)
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/pkey.py", line 255, in _read_private_key_file
    data = self._read_private_key(tag, f, password)
  File "/home/test/venv/lib/python3.4/site-packages/paramiko/pkey.py", line 264, in _read_private_key
    raise SSHException('not a valid ' + tag + ' private key file')
paramiko.ssh_exception.SSHException: not a valid EC private key file

If ~/.ssh/id_rsa does exis, the proper exception is raised:

paramiko.ssh_exception.AuthenticationException: Authentication failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions