Skip to content

pkey: check new openssh format key type - #1606

Closed
ploxiln wants to merge 2 commits into
paramiko:2.7from
ploxiln:fix_pkey_type_check_upstream
Closed

ploxiln wants to merge 2 commits into
paramiko:2.7from
ploxiln:fix_pkey_type_check_upstream

Conversation

@ploxiln

@ploxiln ploxiln commented Jan 21, 2020 •

Copy link
Copy Markdown
Contributor

needs to raise SSHException for wrong type
for SSHClient._auth() to detect type class for key_filenames

fixes #1590

needs to reliably fail with SSHException,
for SSHClient._auth() to detect type class for key_filenames
needs to raise SSHException for wrong type
for SSHClient._auth() to detect type class for key_filenames
@calebstewart

Copy link
Copy Markdown

Is there anything pending for this to be merged? This appears to provide a fix for #1839, which is plaguing me currently.

@onstring

onstring commented Jul 2, 2021

Copy link
Copy Markdown

wonder when could we get this fix merged? I am troubled with an issue caused by this.

@jeffctr

jeffctr commented Jul 7, 2021

Copy link
Copy Markdown

I run with the changes suggested in this PR but ti does not work either. Is there any solution to this?


Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/paramiko/transport.py", line 1898, in run
    self._check_banner()
  File "/usr/local/lib/python3.7/site-packages/paramiko/transport.py", line 2055, in _check_banner
    'Error reading SSH protocol banner' + str(e)
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

Exception: Error reading SSH protocol banner
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/paramiko/transport.py", line 2050, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/usr/local/lib/python3.7/site-packages/paramiko/packet.py", line 360, in readline
    buf += self._read_timeout(timeout)
  File "/usr/local/lib/python3.7/site-packages/paramiko/packet.py", line 572, in _read_timeout
    raise EOFError()
EOFError

riccardomurri added a commit to gc3pie/gc3pie that referenced this pull request Aug 5, 2021
This is due to a bug in Paramiko, see paramiko/paramiko#750 and paramiko/paramiko#1606

Thanks to @martinschorb for suggesting porting this piece of code over from
ElastiCluster's elasticluster/elasticluster@50223b3

Fixes issue #669
@ghost

ghost commented Aug 9, 2021

Copy link
Copy Markdown

Any progress on this yet, I am as well stuck at the same issue

@Mooreel

Mooreel commented Dec 10, 2021

Copy link
Copy Markdown

This still is an issue. I can't use RSA, it always treats my keys as DSA

@ploxiln

ploxiln commented Dec 11, 2021

Copy link
Copy Markdown
Contributor Author

For what it's worth, this is fixed in my fork "paramiko-ng" since version 2.6

@ghost

ghost commented Jan 12, 2022

Copy link
Copy Markdown

+1 for merging this.

Using paramiko-ng in the meantime

@bitprophet bitprophet added this to the Next bugfix milestone Jan 21, 2022
@m1009d

m1009d commented Mar 10, 2022 •

Copy link
Copy Markdown

Hi guys,
seems like this issue is not in 2.8.1, for me everything is working in this version but not in the latest 2.9.2.

@aasifkhan7

Copy link
Copy Markdown

Hi guys, seems like this issue is not in 2.8.1, for me everything is working in this version but not in the latest 2.9.2.

+1 . this worked for me as well.

Also, what is the blocker for merging this @ploxiln ?

@ploxiln

ploxiln commented Apr 9, 2022

Copy link
Copy Markdown
Contributor Author

It needs attention from the maintainer, which I am not.

In the meantime, you could possibly use my fork https://github.com/ploxiln/paramiko-ng/

@bskinn

bskinn commented Apr 11, 2022

Copy link
Copy Markdown
Contributor

This issue/PR is milestoned for the next bugfix paramiko release. Timing will depend on @bitprophet's prioritization among all of paramiko, invoke and fabric, within his weekly time allotted to open-source, so a precise timeline/due-date isn't really available.

@bskinn bskinn added the Keys label May 24, 2022

@bskinn bskinn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor bit of docs

Comment thread paramiko/pkey.py
raise Exception("Not implemented in PKey")

def _read_private_key_file(self, tag, filename, password=None):
def _read_private_key_file(self, tag, pfx, filename, password=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the new parameter to the docstring, since even though the method is private it's got the documentation present. Thanks for the patch!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for docstring:

         :param str tag: ``"RSA"`` or ``"DSA"``, the tag used to mark the
             data block.
+        :param str pfx: expected (prefix of) public key type, e.g. "ssh-rsa".
         :param str filename: name of the file to read.

@jeffguorg

jeffguorg commented Nov 15, 2023 •

Copy link
Copy Markdown

try this if you cannot wait or upgrade paramiko

ssh-keygen -m PEM -p

@ploxiln ploxiln closed this Mar 17, 2025
@ploxiln
ploxiln deleted the fix_pkey_type_check_upstream branch March 17, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cryptography.exceptions.InternalError: Unknown OpenSSL error